Search Results

Search found 24043 results on 962 pages for 'private methods'.

Page 104/962 | < Previous Page | 100 101 102 103 104 105 106 107 108 109 110 111  | Next Page >

  • Is it possible to use AutoMapper to wrap methods?

    - by Woj
    I have two classes: public class TestClass1 { public int TestInt { get; set; } public void TestMethod() { // Do something } } public class TestClass2 { public int TestInt { get; set; } public void TestMethod() { // Do something } } I want to create interface that I can use for both classes. The easiest solution is to implement the interface on TestClass1 and TestClass2 but I don;t have access to the implementation of these classes (external dll). I was wondering if I can create new interface and use AutoMapper to map TestClass1 and TestClass2 to ITestInterface: public interface ITestInterface { int TestInt { get; set; } void TestMethod(); }

    Read the article

  • Why is 'virtual' optional for overridden methods in derived classes?

    - by squelart
    When a method is declared as virtual in a class, its overrides in derived classes are automatically considered virtual as well, and the C++ language makes this keyword virtual optional in this case: class Base { virtual void f(); }; class Derived : public Base { void f(); // 'virtual' is optional but implied. }; My question is: What is the rationale for making virtual optional? I know that it is not absolutely necessary for the compiler to be told that, but I would think that developers would benefit if such a constraint was enforced by the compiler. E.g., sometimes when I read others' code I wonder if a method is virtual and I have to track down its superclasses to determine that. And some coding standards (Google) make it a 'must' to put the virtual keyword in all subclasses.

    Read the article

  • How do I unit test the methods in a method object?

    - by Sancho
    I've performed the "Replace Method with Method Object" refactoring described by Beck. Now, I have a class with a "run()" method and a bunch of member functions that decompose the computation into smaller units. How do I test those member functions? My first idea is that my unit tests be basically copies of the "run()" method (with different initializations), but with assertions between each call to the member functions to check the state of the computation. (I'm using Python and the unittest module.)

    Read the article

  • Should I always release self for failed init methods?

    - by leo
    Should I always release self when there is a failure inside init, or should I only do so if I have initialized instance variables first? To put it another way, is this pattern valid? Is there a time when I shouldn't release self inside an init method, or should I assume that if the control flow enters init, self has at least a retain count of 1? - (id)init { if ((self = [super init]) == nil) { [self release]; return nil; } //do some init stuff if (somethingFailed) { [self release]; return nil; } return self; }

    Read the article

  • What is the effect of final variable declaration in methods?

    - by Finbarr
    Classic example of a simple server: class ThreadPerTaskSocketServer { public static void main(String[] args) throws IOException { ServerSocket socket = new ServerSocket(80); while (true) { final Socket connection = socket.accept(); Runnable task = new Runnable() { public void run() { handleRequest(connection); } }; new Thread(task).start(); } } } Why should the Socket be declared as final? Is it because the new Thread that handles the request could refer back to the socket variable in the method and cause some sort of ConcurrentModificationException?

    Read the article

  • What's the preferred way to use helper methods in Ruby?

    - by DR
    Disclaimer: Although I'm asking in context of a Rails application, I'm not talking about Rails helpers (i.e. view helpers) Let's say I have a helper method/function: def dispatch_job(job = {}) #Do something end Now I want to use this from several places (mostly controllers, but also a few BackgrounDRb workers) What's the preferred way to do this? I can think of two possibilities: 1. Use a class and make the helper a static method: class MyHelper def self.dispatch_job(job = {}) end end class MyWorker def run MyHelper.dispatch_job(...) end end 2. Use a module and include the method into whatever class I need this functionality module MyHelper def self.dispatch_job(job = {}) end end class MyWorker include MyHelper def run dispatch_job(...) end end 3. Other possibilities I don't know yet ... The first one is more Java-like, but I'm not sure if the second one is really an appropriate use of Ruby's modules.

    Read the article

  • Why does PHP 5.2 disallow abstract static class methods?

    - by Artem Russakovskii
    After enabling strict warnings in PHP 5.2, I saw a load of strict standards warnings from a project that was originally written without strict warnings: Strict Standards: Static function Program::getSelectSQL() should not be abstract in Program.class.inc The function in question belongs to an abstract parent class Program and is declared abstract static because it should be implemented in its child classes, such as TVProgram. I did find references to this change here: Dropped abstract static class functions. Due to an oversight, PHP 5.0.x and 5.1.x allowed abstract static functions in classes. As of PHP 5.2.x, only interfaces can have them. My question is: can someone explain in a clear way why there shouldn't be an abstract static function in PHP?

    Read the article

  • Can I detect unused extra parameters passed to javascript methods?

    - by Pablojim
    In Javascript I can call any method with more than the necessary amount of parameters and the extra parameters are silently ignored. e.g. letters = ['a','b','c'] //correct letters.indexOf('a') //This also works without error or warning letters.indexOf('a', "blah", "ignore me", 38) Are there ways to detect cases where this occurs? My motivation is that in my experience cases where this occurs are usually bugs. Identification of these by code analysis or at runtime would help track these errors down. These cases are especially prevalent where people are expecting alterations to base types which may not have occurred. Logging a warning where this happens e.g. Date.parse('02--12--2012', 'dd--MM--YYYY') Notes: To be clear I would like a solution that doesn't involve me sprinkling checks all over my code and other peoples' code.

    Read the article

  • How to Call methods I see in a wsdl file someone linked me to?

    - by Derek
    Hi all, I am not a Java programmer by trade. C and Fortran mostly. However, I have this one-off project someone wants done. Connect to some web-based database and retrieve some data from it. I asked around, and someone finally linked me to a WSDL page. I click on this link, and I see a huge XML looking file. If I am writing a stand-alone java application, how do I go about calling these (promising looking) method names that I see in the wsdl. You know "getCoordinates" is there, but i have no idea how to call that method. After googling, I am finding a lot of different ways, and I am not sure what is the best way for my simple application. Thanks

    Read the article

  • How to pass variables to slot methods in QT?

    - by Neko
    Hi. I'm making a little chat messenger program, which needs a list of chat channels the user has joined. To represent this list graphically, I have made a list of QPushButtons, which all represent a different channel. These buttons are made with the following method, and that's where my problem kicks in: void Messenger::addToActivePanels(std::string& channel) { activePanelsContents = this->findChild<QWidget *>(QString("activePanelsContents")); pushButton = new QPushButton(activePanelsContents); pushButton->setObjectName("pushButton"); pushButton->setGeometry(QRect(0, 0, 60, 60)); pushButton->setText(""); pushButton->setToolTip(QString(channel.c_str())); pushButton->setCheckable(true); pushButton->setChecked(false); connect(pushButton, SIGNAL(clicked()), this, SLOT(switchTab(channel))); } (activePanelContents is a QWidget that holds the list.) The point is that each button should call the switchTab(string& tabname) method when clicked, including the specific channel's name as variable. This implementation doesn't work though, and I haven't been able to find out how to properly do this, even after reading several pages on it on the internet. Can anybody please tell me how to do this? It'd be greatly appreciated, as always. :)

    Read the article

  • Which of these methods provides for the fastest page loading?

    - by chromedude
    I am building a database in MySQL that will be accessed by PHP scripts. I have a table that is the activity stream. This includes everything that goes on on the website (following of many different things, liking, upvoting etc.). From this activity stream I am going to run an algorithm for each user depending on their activity and display relevant activity. Should I create another table that stores the activity for each user once the algorithm has been run on the activity or should I run the algorithm on the activity table every time the user accesses the site? UPDATE:(this is what is above except rephrased hopefully in an easier to understand way) I have a database table called activity. This table creates a new row every time an action is performed by a user on the website. Every time a user logs in I am going to run an algorithm on the new rows (since the users last login) in the table (activity) that apply to them. For example if the user is following a user who upvoted a post in the activity stream that post will be displayed when the user logs in. I want the ability for the user to be able to access previous content applying to them. Would it be easiest to create another table that saved the rows that have already been run over with the algorithm except attached to individual users names? (a row can apply to multiple different users)

    Read the article

  • Is it OK to set state within Event Raising methods?

    - by Greg
    I ran across this pattern in the code of a library I'm using. It sets state within the event raising method, but only if the event is not null. protected virtual void OnMyEvent(EventArgs e) { if(MyEvent != null) { State = "Executing"; // Only sets state if MyEvent != null. MyEvent(this,e); } } Which means that the state is not set when overriding the method: protected override void OnMyEvent(EventArgs e) { base.OnMyEvent(e); Debug.Assert( State == "Executing" ); // This fails } but is only set when handling the event: foo.MyEvent += (o, args) => Debug.Assert(State == "Executing"); // This passes Setting state within the if(MyEvent != null) seems like bad form, but I've checked the Event Design Guidelines and it doesn't mention this. Do you think this code is incorrect? If so, why? (Reference to design guidelines would be helpful). Edit for Context: It's a Control, I'm trying to create subclass of it, and the state that it's setting is calling EnsureChildControls() conditionally based upon there being an event handler. I can call EnsureChildControls() myself, but I consider that something of a hack.

    Read the article

  • C#. Where struct methods code kept in memory?

    - by maxima120
    It is somewhat known where .NET keeps value types in memory (mostly in stack but could be in heap in certain circumstances etc)... My question is - where is the code of the struct? If I have say 16 byte of data fields in the struct and a massive computation method in it - I am presuming that 16 byte will be copied in stack and the method code is stored somewhere else and is shared for all instances of the struct. Are these presumptions correct?

    Read the article

  • Methods for implementing and using graphs of nodes in C++?

    - by DistortedLojik
    I am working on a research project that deals with social networks. I have done most of the backbone of the program in C++ and am now wanting to implement a way to create the graph of nodes and the connections as well as a way to visualize the connections between people. I have looked a little into Lemon and the Boost graph library, but was wondering which one would be easier to learn and implement or if I should just code my own.

    Read the article

  • Override the methods of classes from a .war file.

    - by Sweety
    I have a base application war file say homeApp.war. This contains default operations which user can carry out on the web browser. Now I need to extend the operations available on the same application using that .war file. Like I need to add the extra menus, some shortcuts like icon for log out etc. Please let me know how can I use this .war file to extend the operations and also fix the already existing issues on the application. This web application uses java server faces.

    Read the article

  • Can we execute methods / code in XCcode just like in Visual Studio?

    - by balexandre
    Visual Studio is one of the best developer IDE of all times, and now was improved with multithreading debugging and much more. My question is regarding Xcode and the ability to execute code just like we do in Visual Studio. Let's assume an object in a view and I want to run, let's say: [pickerView setHidden:YES]; in a breakpoint just to see if in that break point I could actually hide the object. I can't find any place for this in the XCode Debugger Am I missing something or I can't execute code that is not in the files already? like in Visual Studio Watch List or Immediate Window

    Read the article

< Previous Page | 100 101 102 103 104 105 106 107 108 109 110 111  | Next Page >