methods

"Short circuiting" void methods with Moq?

Hi, my team has made the decision recently to use Moq as our mocking framework for its tremendous flexibility and highly readable syntax. As we're new to it, I'm stumbling on what appears to be simple questions--searches (here, Google, etc.) find plenty of discussions on other nuances of Moq, but not necessarily what I'm after, and the ...

Why is Method#arity called, well, arity?

Hi All, In Ruby, I know that Method#arity will return a value representing the number of arguments accepted by a method, however I do not know why it is called arity. Can anyone provide some insight into why it would exist in such a seemingly random namespace? and, how do you pronounce it? THX :) -C ...

Dynamically call a static variable (array)

Hello everyone. Here's my question for today. I'm building (for fun) a simple templating engine. The basic idea is that I have a tag like this {blog:content} and I break it in a method and a action. The problem is when I want to call a static variable dynamically, I get the following error . Parse error: parse error, expecting `','' or ...

iPhone Development - Setting up a view in a view controller

Hi, I'm learning to develop for iPhone without Interface Builder (a personal preference), and I'm not sure which function of a view controller I should be setting up the view in: init, viewDidLoad, or loadView. I read somewhere to only use init for the view controller, if anything, and not setting up the view as it could cause problems. ...

Accessing singleton methods in PHP

Hi, I'm just starting my journey into OOP - and I'm currently trying to roll my own MVC - purely for learning purposes. I'm working through a tutorial in the Apress PHP-Objects Patterns Practice book. I've created a registry singleton object using the private __construct/__clone technique: class Registry { private static $instance; ...

good name for a method that adds to a container if not aleady there

What's a good name for a method that adds something to a container if it's not already there, i.e. void AddCustomerToList(CustomerList list, Customer customer) but that name does not properly convey that it won't be added if it's not there already. What is a better name? AddCustomerToListIfNotThereAlready? EnsureCustomerInList? ...

C++ Overriding Methods

I can't figure out what is up with this. I have a Scene class that has a vector of Entities and allows you to add and get Entities from the scene: class Scene { private: // -- PRIVATE DATA ------ vector<Entity> entityList; public: // -- STRUCTORS --------- Scene(); // -- PUBLIC METHODS ---- void ad...

General programming - calling a non void method but not using value

This is general programming, but if it makes a difference, I'm using objective-c. Suppose there's a method that returns a value, and also performs some actions, but you don't care about the value it returns, only the stuff that it does. Would you just call the method as if it was void? Or place the result in a variable and then delete it...

EJB 3 Transaction attribute for read only method

I have a method that returns lot of data, should I use @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) for this method. The method perform a JPA query an loads the full content of a table (about 1000 rows). ...

C++ method declaration question

I have some code in Image.cpp: Image::Image( int width, int height, int depth ) : m_sFileName(0) { ... } and in Image.h: class Image: public DrawAble, public RenderAble { ... private : std::string *m_sFileName; }; My question is: what is happening with m_sFilename in the first line? I guess it is set to NULL...

How does System.Void type specify a return value type for a method that does not return a value?

Is this the actual type methods without a return value return? If so, where is the distinction that "nothing" is returned made? ...

C# virtual static method

Hi, Why is static virtual impossible? Is C# dependent or just don't have any sense in the OO world? I know the concept has already been underlined but I did not find a simple answer to the previous question. Thx ...

What to call a method that finds or creates records in db

This question might seem stupid but i nonetheless i believe it's a worth asking questioin. I work on some web application when we use tags which are attached to articles. When adding new article users provides a list of tags he wish to associate with his new article. So when the form is submitted and my MVC controller processes reques...

AutoRun Methods

Hi all, I am using NSIS for making an installer. 1.I have to just execute Mysql setup in the first step 2.And later on the successful execution of the step1 (that is installing the mysql in the system) I need to execute my database scripts. 3.now i need to run my myproj.exe Here the problem is installer is directly running all the ...

Overriding / Swizzling methods from an existing shared delegate

Is it possible to override ONLY CERTAIN functions from an exisiting delegate, without ourself being a delegate totally? I tried replacing the target IMP with mine, didn't work :'( More detail: +[SomeClass sharedDelegate] -[sharedDelegate targetMethodToBeOverridden:Arg:] //OUR method needs to be called, not this Method *targetMetho...

Rewriting method calls within compiled Java classes

I want to replace calls to a given class with calls to anther class within a method body whilst parsing compiled class files... or put another way, is there a method of detecting usages of a given class in a method and replacing just that part of the method using something like javaassist. for example.. if I had the compiled version of...

Python : Assert that variable is instance method?

How can one check if a variable is an instance method or not? I'm using python 2.5. Something like this: class Test: def method(self): pass assert is_instance_method(Test().method) ...

Method unexpectedly stopping short of completion, c# 2008 .net 3.5

Ok so this is some code im writing to help me out on a game, anyway this stumped me... ok so this calls my method: private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e) { if (webBrowser1.Document.Url.OriginalString.Contains(@"page=logs")) { AttatchProcess Test = new Attatc...

Datatable select method ORDER BY clause

HI, I 'm trying to sort the rows in my datatable using select method. I know that i can say datatable.select("col1='test'") which in effect is a where clause and will return n rows that satisfy the condition. I was wondering can i do the following datatable.select("ORDER BY col1") ---col1 is the name of hte column I tried datatab...

pass reflected enum to method.invoke java

If you have an enum that you are accessing via reflection how would you pass it's value into method.invoke call. Would it be something like (shown as a static method for simplicity) Class enumClazz = Class.forName("mypkg.MyEnum",true,MyClassLoader); Class myReflectedClazz = Class.forName("mypkg.MyClass",true,MyClassLoader); ...