method-signature

When to use method overloads VS "request" object

What is the best "rule of thumb" to determine when to use method overloads and when to use a separate "request" class? for example: MakePancakes(int size) MakePancakes(int size, bool addBlueBerries) MakePancakes(int size, bool addBlueBerries, ...) As opposed to: MakePancakes(PancakeOptions options) Is it best to stick to one way o...

Is it possible to pass a method as an argument in Objective-C?

I have a method that varies by a single method call inside, and I'd like to pass the method/signature of the method that it varies by as an argument... is this possible in Objective C or is that too much to hope for? ...

Why can't two methods be declared with the same signature even though their return types are different?

Duplicate: http://stackoverflow.com/questions/442026/function-overloading-by-return-type Maybe this is a very silly question but I don't understand why I can't declare two methods that have the same signature when they have different return types. public class MyClass { private double d = 0; public double MyMethod() { ...

Diff on Java class signatures?

Given two JAR files for the same Java library, is there a tool that will do a diff of the method signatures between the two jar files? ...

How to get method signatures from a jar file?

I have a third-party jar file that comes with the javadocs for only part of the API. Is there a way to reverse engineer the jar file to obtain a complete listing of classes and methods? ...

Design question: pass the fields you use or pass the object?

I often see two conflicting strategies for method interfaces, loosely summarized as follows: // Form 1: Pass in an object. double calculateTaxesOwed(TaxForm f) { ... } // Form 2: Pass in the fields you'll use. double calculateTaxesOwed(double taxRate, double income) { ... } // use of form 1: TaxForm f = ... double payment = calculateT...

Lots of "incompatible signature" errors on Windows but not on Mac OS X with Flex 4 Gumbo.

I have a pure Action Script 3 project which I am compiling with the Flex 4 SDK. I have a standard Makefile which automatically invokes compc, mxmlc, and asdoc as appropriate. The project is compiling cleanly with no errors or warnings on my Mac OS X 10.4+ computer; however, when sharing it with a coworker developing on Windows XP (with C...

Can Java methods return type Enum?

I could be wrong but I'm guessing from this previous SO post that, since an enum in Java cannot be declared locally, that therefore it is therefore problematic for a method to return type Enum? I can declare that a method should return an Enum (see below) but how would one then go about implementing such a method to return anything othe...

Factory method signature for aggregate root

I want to write a factory method to instantiate an entity that is an aggregate root. Should the method accept the aggregated child entities and values as instantiated objects, or should it accept only primitive types? For example, if I had an entity Computer composed of a Processor and a Memory object, should the factory method take th...

Java - getting the signature of a method in an interface, and the same for its Proxy implementation

I'm looking for a way to extract the essence of a signature in Java. The reason is that I want to use the signature as a unique key in a Map for my java.lang.reflect.Proxies. With this code: public interface MyInterface { public int compute(String s); } ... public static void main (String... args) throws Exception { InvocationHand...

Java interface: method signature declared as throws Exception; implemented as throws a subclass of Exception [CLOSED]

Hi all, I have the following interface declaration: public interface SomeInterface { void someMethod() throws Exception; } I use a third party to generate an implementation of this class (JavaCC - for the curious) The generated class looks naively like this: public class SomeClass implements SomeInterface { public void so...

Return Value for "should cancel"

I have a method DoCleanUp(), which will ask user to proceed and then clear current workspace. It will return if user choose to cancel this process. My question is, which signature is best to indicate a "cancel"? bool DoCleanUp(); // return false to indicate canceled. bool DoCleanUp(); // return true to indicate this method should ...

Is method signature in PHP a MUST or SHOULD?

I mean if it's called with $request which is not instance of sfWebRequest ,will it be fatal,or just a warning? class jobActions extends sfActions { public function executeIndex(sfWebRequest $request) { $this->jobeet_job_list = Doctrine::getTable('JobeetJob') ->createQuery('a') ->execute(); } // ... } ...

Why varargs should be the last in method signature?

If I try to write a method like below public void someStuff(Object ... args, String a ) I get this error The variable argument type Object of the method someStuff must be the last parameter. I don't fully understand the requirement of variable argument type to be the last. Any inputs will be helpful. ...

How Do I Handle Conflicts in Overloaded Method Signatures?

Hi. I have a feeling this question is a can of worms but I am going to ask anyway... :) I have a method: private MembershipUser GetUserFromReader(SqlDataReader reader) And I want overload this method with a different return type: private User GetUserFromReader(SqlDataReader reader) But the compiler complains that the two method...

What does this signature mean(&) in PHP?

public function & get($name, $default = null) Why &? ...

c++ signatures, pointers

Hello, what's the difference between these signatures? T * f(T & identifier); T & f(T & identifier); T f(T & identifier); void f(T * identifier); void f(T & identifier); void f(T identifier); I met pointers in c, but the amperstand in function signature is new for me. Can Anyone explain this? ...

private static <T> T cloneX(T x) - What does the <T> signify here?

In the above declaration, what is the <T> for? I would like to know the difference between having <T> and not having it? How does it affect the code? ...

Delegates and ParamArray - Workaround Suggestions?

Some predefined methods contain a ParamArray in their signature. Delegates, however, cannot contain a ParamArray in their signature. Question: Assume you wish to create a delegation mechanism for a specific method which requires a ParamArray. How would you work around this constraint? EDIT: just to make clear, assume you cannot change ...

Why aren't classes in .NET 4 covariant?

Possible Duplicate: Why isnt there generic variance for classes in C# 4.0? As a rookie programmer I have a couple of questions about variance in .NET 4. Not so much about how it works, but why certain things are not variant and if other people would find this useful. Question 1: I know that interfaces and delegates can be c...