Repeat yourself, do more than one thing, and... — programming is terrible


51 bookmarks. First posted by nicferrier 15 days ago.


As Sandi Metz put it, “duplication is far cheaper than the wrong abstraction”.

You can’t really write a re-usable abstraction up front. Most successful libraries or frameworks are extracted from a larger working system, rather than being created from scratch. If you haven’t built something useful with your library yet, it is unlikely anyone else will. Code reuse isn’t a good excuse to avoid duplicating code, and writing reusable code inside your project is often a form of preemptive optimization.

When it comes to repeating yourself inside your own project, the point isn’t to be able to reuse code, but rather to make coordinated changes. Use abstractions when you’re sure about coupling things together, rather than for opportunistic or accidental code reuse—it’s ok to repeat yourself to find out when.
software-development  cultural-norms  refactoring  advice  to-write-about 
8 hours ago by Vaguery
2018-08-05 Repeat yourself, do more than one thing, and rewrite everything If you ask a programmer for advice—a terrible idea—they might tell you something like…
from instapaper
yesterday by wjbr
Repeat yourself, do more than one thing, and rewrite everything
If you ask a programmer for advice—a terrible idea—they might tell you something like the following: Don’t repeat yourself. Programs should do one thing and one thing well. Never rewrite your code from scratch, ever!.

Following “Don’t Repeat Yourself” might lead you to a function with four boolean flags, and a matrix of behaviours to carefully navigate when changing the code. Splitting things up into simple units can lead to awkward composition and struggling to coordinate cross cutting changes. Avoiding rewrites means they’re often left so late that they have no chance of succeeding.

The advice isn’t inherently bad—although there is good intent, following it to the letter can create more problems than it promises to solve.

Sometimes the best way to follow an adage is to do the exact opposite: embrace feature switches and constantly rewrite your code, pull things together to make coordination between them easier to manage, and repeat yourself to avoid implementing everything in one function..

This advice is much harder to follow, unfortunately.
advice  prog  blog 
2 days ago by kmt
'As Sandi Metz put it, “duplication is far cheaper than the wrong abstraction”.' <-- this is the best programming advice ever
programming 
8 days ago by aparrish
Invoking the ‘single responsibility principle’, programmers have been known to brutally decompose software into a terrifyingly large number of small interlocking pieces—a craft rarely seen outside of obscenely expensive watches, or bash.
programming  advice 
12 days ago by wholewheattoast
repeat yourself, do more than one thing, and rewrite everything!
13 days ago by kurver
In the end, we call our good decisions ‘clean code’ and our bad decisions ‘technical debt’, despite following the same rules and practices to get there.
code  advice  programming 
13 days ago by tedw
The problem with always using an abstraction is that you’re preemptively guessing which parts of the codebase need to change together. “Don’t Repeat Yourself” will lead to a rigid, tightly coupled mess of code. Repeating yourself is the best way to discover which abstractions, if any, you actually need.
[…]
although one class might do two things in a rather nasty way, disentangling it isn’t of much benefit when you end up with two nasty classes with a far more complex mess of wiring between them.
[…]
Technical debt, or code the seniors wrote that we can’t be rude about, accrues until all change becomes hazardous. It is only when the system is at breaking point that a rewrite is even considered an option.
[…]
In the end, we call our good decisions ‘clean code’ and our bad decisions ‘technical debt’, despite following the same rules and practices to get there.
nützlich  Meinungen  Projektmanagement  Entwicklung  Programmierung  tested  Konzeption 
13 days ago by Stolzenhain
2018-08-05 Repeat yourself, do more than one thing, and rewrite everything If you ask a programmer for advice—a terrible idea—they might tell you something like…
instapaper 
13 days ago by ckolderup
2018-08-05 If you ask a programmer for advice—a terrible idea—they might tell you something like the following: Don’t repeat yourself. Programs should do one…
from instapaper
14 days ago by aviflax
RT : repeat yourself, do more than one thing, and rewrite everything!
from twitter_favs
14 days ago by briantrice
RT : There’s some truth to this , but the problem it attributes to DRY isn’t inherent.

If you ha…
from twitter
15 days ago by orta
RT : repeat yourself, do more than one thing, and rewrite everything!
from twitter
15 days ago by mjr5749
- Don't Repeat Yourself
-- Can lead to rigid, tightly coupled mess of code.
-- duplication is far cheaper than the wrong abstraction
-- Create abstractions for things that change together
- Modularity
-- Are booleans a sign of code that maybe we have reduced too much?
-- Modules are often changed because they are the easiest to change, not because they are the best place to make the change.
- Rewrite Everything
-- We rarely understand the previous system, and many of its properties are accidental.
-- If a replacement isn't doing anything useful after three months, odds are it will never do anything useful.

"In the end, we call our good decisions ‘clean code’ and our bad decisions ‘technical debt’, despite following the same rules and practices to get there."
15 days ago by aesterline
repeat yourself, do more than one thing, and rewrite everything!
from twitter_favs
15 days ago by feltnerm
repeat yourself, do more than one thing, and rewrite everything!
from twitter_favs
15 days ago by nicferrier
repeat yourself, do more than one thing, and rewrite everything!
from twitter_favs
15 days ago by indirect
repeat yourself, do more than one thing, and rewrite everything!
from twitter_favs
15 days ago by moderation
repeat yourself, do more than one thing, and rewrite everything!
from twitter_favs
15 days ago by mike_moran