views:

34

answers:

2

Hi,

I started reading Holub's pattern book and not sure if this is a mistake (pg 59-61).

He has in listing 2-3

public interface Employee
{ void youAreFired();
}

public static class EmployeeFactory
{  private Factory() {}

 public static Employee create()
 {   return new Peon();
 }
 }

/* package*/ class Peon implements Employee
{   public void youAreFired()
    {  //lots of code
    }
 }

He is using Employee.Factory.create(). Factory is not a inner class of Employee, so how is using that?

Then two pages down he says Employee.Factory is a singleton. How? I think its a typo, Factory or Employee.Factory should actually be EmployeeFactory. I hope I am not missing something major in Java programming!

+1  A: 

I bet he just meant "EmployeeFactory" in both those cases. It looks like just a typo.

Andy White
+1  A: 

yeb there is single typo only:
Proposed fix:
the line public static class EmployeeFactory => public static class Factory

revise what you wrote after considering above fix shall result in clearing the vision.

jadook