quote:Original post by cedricl
This, I don''t understand. Could you explain it? Did you mean that abstract base classes should have a protected contructor?
Presumably, he means that polymorphic classes should be created by a factory which has specially privileged access to the ctor. The same argument regarding encapsulation applies to object creation as to anything - how and where the object is created should be transparent to the user of the object. The way to ensure the user does not dictate how the object comes into being is to disable the ctor and make them go via the factory.
For every design heuristic, there is an equal and opposite reaction. In this case, the danger is of premature generalisation.