Skip to main content
1 of 2
klaar
  • 121
  • 9

When I implement a base class that requires extra initialisation information or links to other objects before it becomes useful, I tend to make that base class abstract, then define several abstract methods in that class that are used in the flow of the base class (like abstract Collection<Information> get_extra_information(); and abstract Collection<OtherObjects> get_other_objects(); which by contract of inheritance must be implemented by the concrete class, forcing the user of that base class to supply all the things required by the base class.

Thus when I implement the base class, I immediately and explicitly know what I have to write to make the base class behave correctly, since I just need to implement the abstract methods and that's it.

klaar
  • 121
  • 9