loading...

re: When DRY Doesn't Work, Go WET VIEW POST

FULL DISCUSSION
 

If you keep abstracting the code out then you will have a bunch of very small methods. The new definition of 'fancy button' or whatever can inherit from 'button' and override the bit that is different.

 

If you have a third level branch with a certain feature, and then you need that same feature in a very distant other 4 level branch, then inheritance will not save you. There's a reason why the main lessen of OOP design patterns (the gang of four book in particular) is ' favour composition over inheritance'.

 

Not to mention, how much could you have gotten done (duplicating early if necessary) for multiple features, rather than "keep extracting the code out" for one (while guessing at all of your abstractions' possible use/edge cases through some sort of crystal ball)?

My general rule for deduplicatimg is that 2 times is okay and three can be. Every rule for style and organization must be applied with knowledgeable consideration.

Code of Conduct Report abuse