Log in

View Full Version : Constructor implementation to the abstract class or not?


timoFromMikkeli
Feb 3, 2010, 06:52 AM
If there are instance variables in the abstract base class I can implement a constructor to this abstract class. However, is it "more right" to implement only "setters" and "getters" to this abstract base class and use those public methods (setters) in my derived class's constructor to initialize the inherited instance variables? Both ways work, but which one is "more to the syntax and semantics"?? I feel uneasy to create a constructor to the abstract base class because it feel unlogical...

jmd814
Feb 4, 2010, 11:04 AM
From code maintainability and understandability stand points it does make more sense to simply provide getters for the variables that you want to expose from the abstract class.

timoFromMikkeli
Feb 4, 2010, 12:12 PM
From code maintainability and understandability stand points it does make more sense to simply provide getters for the variables that you want to expose from the abstract class.

Thank You very much for Your viewpoint!

Greetings,

timoFromMikkeli