4 ms·
DRY only paired with the rule of three (or more)
by laerus 3y ago
DRY only paired with the rule of three (or more)
- carlmr 3y agoThat, or the code block is sufficiently big and similar. I remember a ex-colleague of mine who copied a 1000 line function, changed a parameter, and didn't see anything wrong with it.
- leidenfrost 3y agoWhy do you have a 1000 line function in the first place? Sounds like an entire class of methods in a single structure.
- sodapopcan 3y agoI had a coworker who did similar. It was essentially the entire frontend for an order application (back in the jQuery days), a few thousand lines. That was all copy/pasted, changed to deal with the case of when there are no orders (which only ever happens once since this was an in-house system) and those massive chunks were wrapped in an if/else.
- bcrosby95 3y agoI recently had a junior copy paste a 20 line code block rather than add an extra 'or' to the if statement. Hey, rule of 3 ;) Anyways, guidelines are just guidelines, regardless of what you come up with you can break it.
- erik_seaberg 3y agoI’m not swayed by this rule of three. The experience I have is the reason I reach for a hammer immediately, instead of first trying three rocks to demonstrate that’s still a bad idea.