On 11/13/2013 03:15 AM, Andrei Alexandrescu wrote:
...
- If I know the fully qualified name of a class, there are better ways
to instantiate this class than passing a string containing that name to
Object.factory in order to call the default constructor.

What are the better ways?

Call the default constructor. Call a delegate/virtual function that
calls the default constructor.

Wait, doesn't Object.factory call the default constructor of the created
object?
...

Yes, I was listing some ways to do this that I think are better than calling Object.factory.

Note that most of the time you don't "know"
the name of a class - you get it down the wire during some
deserialization.

You don't want to call the default constructor during deserialization
and you need actual information about the Object layout, so seems to be
an instance of the next point.

If not the default constructor, which constructor?

None, I guess you'd want to create the right object state in memory.

Didn't you say above
that calling the default constructor is good?

If that is what you want to do, yes.

I feel we're talking past
each other.


Maybe.

Reply via email to