valhalla-dev Digest, Vol 17, Issue 3
twhitmore.nz at gmail.com
Thu Dec 31 02:47:25 UTC 2015
Hi Peter, Vitaly, people
Thanks for raising "Factories" -- I'd been thinking about these too. I
guess I am really questioning whether "making Classes into multiple
possible things" is really preferable to "asking a Factory Method to create
the appropriate thing".
Vitaly -- your objection to making constructors into 2nd-class citizens --
by introducing all kinds of variance within the class, we are running the
risk of degrading what was single & clear (the concept of class) into its
own 2nd-class citizen.
If we haven't used factory methods eg. for List.newArrayList() before,
perhaps we should start now?
- Google Guava API use factory methods successfully; even for current
Java, it seems a good design.
- and for our purposes, it provides an ideal place to locate specialization;
- *outside* of a single class (specific implementation) and able to
despatch to type-specific alternate specialized implementations, as
The main limitation with factory methods is multiple dimensions of
type-specificity; eg. separate specialiations on Key and Value of a Map,
for example. Template-style specialization (as Vitaly is currently working
on) can handle that better, but I believe this to be a very much smaller
proportion of the real world problem-space.
More information about the valhalla-dev