name of the design pattern

Hi

I have been studying a piece of code somebody else wrote. I am wondering if this is the Factory Method design pattern that this represents. I am new to patterns and I would be very thankful for any suggestions.

publicclass Creator{

public Person create(String gender){

if (gender.equals(揗?

returnnew Male();

elseif (gender.equals(揊?

returnnew Female();

else

returnnull;

}

}

-

thanks in advance

[1022 byte] By [ilango171a] at [2007-10-3 2:52:25]
# 1

Yes, you are right this is a Factory Method creational design pattern.

See http://en.wikipedia.org/wiki/Factory_method_pattern for more information.

Ussualy class which is used to create instances of other classe called XXXFactory and implemented as singleton.

Regards,

Yevhen

yyaremchuka at 2007-7-14 20:41:24 > top of Java-index,Other Topics,Patterns & OO Design...