Final defenders

Daniel Latrémolière daniel.latremoliere at gmail.com
Wed Aug 8 02:09:05 PDT 2012


> Hi Daniel,
>
> unfortunately, these arguments are going against a basic principal in OO
> programming. You asked so that List knows about the classes that
> implements it.
>
> Z.
I don't think it is against my only real principles of OO programming: 
abstraction and simplicity!

I have nothing against an implementation of these static methods, using 
a service to allow external configuration of the real classes 
implementing List and instantiated by these static methods. It will 
possibly solve your problem of List knowing some default implementation 
classes if you really dislike this, but I don't think it is a real problem.

You will always have a class knowing one subclass as default 
implementation, in all factories (and there is numerous in Java), by 
example:
http://hg.openjdk.java.net/jdk8/jdk8/jaxp/file/dc1ea77ed9d9/src/javax/xml/parsers/SAXParserFactory.java
|public static SAXParserFactory newInstance() {
   try {
     return (SAXParserFactory) FactoryFinder.find(
       /* The default property name according to the JAXP spec */
       "javax.xml.parsers.SAXParserFactory",
       /* The fallback implementation class name */
"com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
   } catch (FactoryFinder.ConfigurationError e) {
     throw new FactoryConfigurationError(e.getException(), e.getMessage());
   }
}
|
Daniel.


More information about the lambda-dev mailing list