Servant is used for providing some behavior to a group of classes. Instead of defining that behavior in each class - or when we cannot factor out this behavior in the common parent class - it is defined once in the Servant.
Please take a look at MoveServant
and Movable
example in the wiki page. What can be the reason so that I will not want to put moveBy
and moveTo
in the parent class for all shapes? In other words why parent class implementing the functionality is worse compared with servant implementing the functionality.
BTW in this sentence "Servant is used for providing some behavior to a group of classes." group of classes
means classes that belong the the same type (class hierarchy)?