Morning X rant. DRY.
@unclebobmartin286.145 Follower
98.404 Aufrufe
37 Kommentare
Kommentare aus dem Originalbeitrag auf X (Twitter)

@daveddev
Didn't you already cover this?
13 Likes

@josecanciani
I like the original take they had in "The Pragmatic Developer" (which afaik was the first using the acronym). They define DRY as: > EVERY PIECE OF KNOWLEDGE MUST HAVE A SINGLE, UNAMBIGUOUS, AUTHORITATIVE REPRESENTATION WITHIN A SYSTEM The idea is not to write less code but rather to avoid having “business logic” (a term we now use to talk about that “knowledge”) defined in more than one place, which will eventually lead to bugs. Here's a thread with my thoughts on it I wrote some time ago:
13 Likes

@mleitz1
I 100% agree with every thing said here One way to summarize dry is Dry is a heuristic not a first principle Use your judgement and you can break the dry heuristic. This is especially true if the code exists in separate contexts Like what Bob said about different modules
7 Likes

@KasperPeulen
The problem is the cost of undoing the wrong consolidations. You should consildate things that change for the same reasons. But seperate those things that change for different reasons. Juniors not being able to spot the difference are the biggest cause of technical debt.
6 Likes

@unclebobmartin
A very nice restatement of the single responsibility principle. Gather together, those things that change for the same reasons. Separate those things that change for different reasons.
10 Likes

@YishengJiang
The real insightful part of the video comes after 3:45 or so when he talks about two identical snippets in differrent modules driven by different forces, then you want to keep them separate fo decoupling purpose.
5 Likes

@ired
also, very very good point on identical snippets of code with different forces on them
4 Likes

@caoimghgin
Excellent breakdown of when to practice DRY and when the juice simply isn't worth the squeeze.
3 Likes

@slopgremlin
All code should be WET Write. Everything. Twice.
3 Likes

@JeffGraw
As a sometimes critic of DRY, I can't disagree with any of that. I think most of the hate for DRY is directed against people that apply it dogmatically, creating hundreds or thousands of little functions that becomes a confusing mess. There are real people out there who advocate for insane practices like "Methods should be no more than x (often single digit) lines." Aside from that, I absolutely love local functions. When you're able to use them, you gain the benefits of DRY with not much detriment, by virtue of locality and limited scope. Am I going to extract three lines used three times? Probably not, unless I can extract it into a local function.
2 Likes

@tploe
"A little copying is better than a little dependency." ~> Go Proverbs,
2 Likes

@YashGouravKar1
that laugh at 1:13 alone was worth the price of admission
1 Like

@SquidTakopi
You said it would be fine as a macro and not a function. But it wasnt a function, it was actually a macro and Linus just called it a function.
1 Like

@Nikki1The
Totally agree, especially the last point. I once trolled co-worker when he was talking about DRY. I asked him to repeat what he just told :D
1 Like

@puppeteer_0
Proud to call myself DRY Absolutist 🫳🏻🎤
1 Like

@vinzloh_dev
this is so good . been struggling to articulate what i practice to the team, this nails it 💯 tq!
1 Like

@foysavas
Many well-intentioned DRY neophytes get this wrong, annoying experienced devs. To DRY or not? First ask what the "destiny" of the observed code pattern is. Only when it's shared, should you apply DRY.
1 Like

@jantoin
Loved the very last point you made. That insight gets lost even with “senior” engineers
1 Like

@yeeeeezos
he’s back

@prahladyeri
Linus was quite right. Kernel maintainers are extra sensitive to SRP violations in core code these days because they can affect stability across 20+ architectures.












