S
Stefan Ram
I read this in the world wide web:
»Having dismissed constructors and static factories, it
seems we need to define a factory class whose instances
will support an interface that includes a method that
constructs the desired objects. How will you create the
factory object? By calling a constructor? Or by defining
a meta-factory? After how many meta-meta-meta- ..
meta-factories do you give up and call a constructor?«
http://gbracha.blogspot.com/2007/06/constructors-considered-harmful.html
One answer that came to my mind:
An application may use a constructor /once/ to get its first
object, thereafter it uses only factory methods of this
object and other objects to get all other objects.
(This might have nothing to do with practical Java
programming, I know.)
It reminds me of Amiga programming, where, in 1985,
programmers learned that there is /one/ fixed address, i.e,
the address 4. So an application would go to address 4 to
find the base address of the system library object (it was
not called »object«, then) and all other objects it would
retrieve directly or indirectly from this object.
»Having dismissed constructors and static factories, it
seems we need to define a factory class whose instances
will support an interface that includes a method that
constructs the desired objects. How will you create the
factory object? By calling a constructor? Or by defining
a meta-factory? After how many meta-meta-meta- ..
meta-factories do you give up and call a constructor?«
http://gbracha.blogspot.com/2007/06/constructors-considered-harmful.html
One answer that came to my mind:
An application may use a constructor /once/ to get its first
object, thereafter it uses only factory methods of this
object and other objects to get all other objects.
(This might have nothing to do with practical Java
programming, I know.)
It reminds me of Amiga programming, where, in 1985,
programmers learned that there is /one/ fixed address, i.e,
the address 4. So an application would go to address 4 to
find the base address of the system library object (it was
not called »object«, then) and all other objects it would
retrieve directly or indirectly from this object.