Re: Breaking the Last Dependency in C++?




Joerg Simon wrote:
> Hi experts,
>
> Short:
> -----------------------------------------------------------------------
> Is there an equivalent technique for a factory like one with refelction
> in Java like in the article of Elisabeth Freeman and Eric Freeman on
> Java.Net?
> -----------------------------------------------------------------------
>
> Article URL:
> http://today.java.net/pub/a/today/2005/04/14/dependency.html
>
> -------

This is a fairly common technique technique in Java, the XML parser and
XSLT transformer factories, for example, all work this way. Freeman
and Freeman aren't really introducing anything new here. Since it
relies on reflection, on being able to create an instance of a class
from the class name, there is nothing directly comparable to it in C++,
which doesn't support that. The closest to this in C++ would be to
have the factory look up an instance factory in a map associated with a
name. The lookup table could be in a dynamic or shared library, and
the names registered in a configuration file, allowing some scope for
extendibility. But in general languages that support reflection offer
much greater scope for exendability.

Regards,
Daniel Parker

.



Relevant Pages

  • Re: Constants, Static, Public, Private
    ... Does there exist a program behaviour which could be implemented using the "FACTORY" keyword, but which could not be implemented without that keyword? ... word 'static' when used in Java. ... public static void main{ ... Classes basically represent a class of objects (e.g. a class called "Dog" might represent the abstract concept of what a dog is like, and how it should behave, while a particular instance of "Dog" represents one particular dog). ...
    (comp.lang.cobol)
  • Re: Constants, Static, Public, Private
    ... Constants were introduced by J4 as a part of COBOL 2002 - a short ... COBOL instance methods are equivalent to public nonstatic methods in Java. ... COBOL factory methods are equivalent to public static methods in Java. ... factory method must invoke instance methods to act on instance data. ...
    (comp.lang.cobol)
  • Constants, Static, Public, Private
    ... Constants were introduced by J4 as a part of COBOL 2002 - a short ... COBOL instance methods are equivalent to public nonstatic methods in Java. ... COBOL factory methods are equivalent to public static methods in Java. ... factory method must invoke instance methods to act on instance data. ...
    (comp.lang.cobol)
  • Re: Breaking the Last Dependency in C++?
    ... Is there an equivalent technique for a factory like one with refelction ... in Java like in the article of Elisabeth Freeman and Eric Freeman on ... On java.net there is an article from Elisabeth Freeman and Eric Freeman, ...
    (comp.object)
  • Re: How to: ClassFactory?
    ... class-name to an interface that won't be checked until runtime. ... > aforementioned class, factory, and interface. ... This is why I don't endorse Java and their fanatic trust in patterns. ... > SecureUser objects or can be passed to the constructor for SecureUser. ...
    (microsoft.public.dotnet.languages.csharp)