Is there a pattern, or structure that guarantees that a subclass will, at a certain stage in it's life cycle will either call certain methods?
I'm looking for something similar to when a class implements a certain interface, it is essentially saying that it promises to implement certain methods.
Anti Pattern? I understand that this may be in-fact some sort of antipattern. I basically need to a sanity check that a collection of subclasses are doing the work they should be doing. If nothing exists, I'll simply write a mini file parser that will do a quick check that the methods are called.
This question is language agnostic, but in this case I'm using C#
You question is not 100% clear, but I assume the first sentence is what you're really looking for:
Is there a pattern, or structure that guarantees that a subclass will, at a certain stage in it's life cycle will either call certain methods, or send certain messages?
I know nothing about that.
You can make the base class abstract
, force all subclasses to implement certain methods by making the methods abstract
and implement the calls depending on object state and lifecycle in the base class. Calling these abstract
methods from base class will invoke their implementations from subclass.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With