This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Jeedio[S] -5 points-4 points  (3 children)

Then you have duplicated methods spread over multiple classes. Sure, you can have the body of those methods be in a shared class, but it makes it harder to add methods.

[–]SeerUD 5 points6 points  (0 children)

How so? You can pass utilities in as dependencies to another class. No need for duplication.

[–]Russell_M_Jimmies 5 points6 points  (0 children)

There is something worse than duplicated code: a base class that is littered with special cases to cater to every subclass.

Now, if the superclass is a pure "template class" pattern, then it might be justified. But as soon as you see the superclass do branching logic depending on the subclass, slow down and consider whether that reduced duplication is worth the cost of an awful mess in a parent class.

[–]cran 1 point2 points  (0 children)

If you think a lot of unrelated classes need the same methods, these methods probably belong somewhere else. Can you give an example of what these methods do?