3 ms·
I am using rule of two. I refactor at the second appearance. I started doing this when programming Ruby on Rails a few years back, where DRY (Don't repeat yours
by guytv 3y ago
I am using rule of two. I refactor at the second appearance.
I started doing this when programming Ruby on Rails a few years back, where DRY (Don't repeat yourself) was a big thing there.
- lostmsu 3y agoI am using rule of 1.5. It's just like rule of 2, but I also name (e.g. make a separate function) any block of code whose result value is not obvious from a single glance.
- tasubotadas 3y agoThat's a mistake that leads to premature generalization
- n2d4 3y agoIt's a mistake to pick any of those rules as an absolute truth. It varies by task, maintenance and time constraints. DRY makes a lot of sense in some cases, but some others even need a rule of four+ (think of heuristics-heavy code). IMO DRY is most useful when working on a codebase owned by someone else than you.