jastrachan | 19 May 19:46 2004
Picon

Re: [groovy-dev] Static factory method

On 19 May 2004, at 18:33, Samuel Pullara wrote:
> If there is going to be a static method on classes that makes new 
> instances, I think it should be called newInstance() like the 
> equivalent reflective constructor invocations.

I like that too - it was my first thought. The tricky bit is how to 
identify the 'real' constructor method. Maybe new()?

lass Point {
     static Point newInstance(x, y) {
	if (x == 0 & y == 0) {
	    return origin
	}
	else {
	    // really do the creation
	    return new(x, y)
	}
     }
}

James
-------
http://radio.weblogs.com/0112098/

Gmane