3 ms·
Yes, it was clear what your point was. My point is that there is code in your Dog class that would do well on its own, irrespective of any supposed Cats or Chic
by hackinthebochs 13y ago
Yes, it was clear what your point was. My point is that there is code in your Dog class that would do well on its own, irrespective of any supposed Cats or Chickens. Separating positioning/movement code and barking code makes real design sense. Separation of Concerns is at times the antithesis of YAGNI.
- vidarh 13y agoYou are assuming that you know upfront which of that code actually will be separate. Some of it may seem very obviously separate, but that does not mean it is clear what the generic version will look like for all practical use cases. E.g. a generic "move" method may look substantially different if it is to only deal with pets that walk on the ground vs. handle pets that fly too. How much do you generalize it in advance before it is too much? If the code really is becoming so large it is a maintenance issue, then sure, yes, separate it anyway. But do it explicitly for that reason.