Instead of dividing the interfaces by the class of clothes, this may be more useful, as others noted that each piece of clothing indicates that it is (headgear, bathrobe, etc.). Although this approach, as a rule, is not related to object-oriented programming, there are probably not many methods that would be applicable to one type of clothing that could not be applied to others (even if in some cases the effect may be “no action” "). For example, if the AnimateResponseToHeadMovement method existed, then TopHat could do something, but LeftSock would not, but the behavior of LeftSock would still be clearly defined. Please note that defining actions is quite expansive, allowing you to take into account situations in which, for example, a human hat may need to be animated in response to their hand movements, because it hung especially low. If the "AnimateResponseToArmMovement" method was not present in the IHeadWear interface, such an answer may not be possible.
The big problem that I suspect will determine how clothing items interact. You can define the "CanBeWornInCombinationWith" method, which contains a list of clothes and reports of conflicts. It is also possible to define a list of “resources” required for each piece of clothing and confirm that there are enough “resources” to cover all the required clothes. Note that this approach can be a little complicated if some clothes choose which resources they require than others (for example, some can only be worn on the right side, while others can be worn). Even defining an interface that allows clothes to determine whether this combination can be worn would be a problem.
Before creating an interface design, I suggest you understand what you are really trying to do; How universal is the need for you to allow interactions between types of clothes and what functions clothes should have.
source share