I'm coding in Python, but the question seems independent of programming language.
I have a class that represents some system check:
class Check:
@abstractmethod
def run()
""" You have to define your own run(). As a result, it must set self._ok. """
...
@property
def is_ok():
return self._is_ok
Then we have a set of checks by subclassing Check class, and they're used in the following way (simplified):
class Checker:
checks = [check1, check2...]
def __call__(self):
for check in self.checks:
if not check.is_ok:
alarm()
The question is: Is it fine to oblige subclass to set some protected object attributes?