The principles war:🏜️DRY vs💋KISS and an unexpected hero😎

The most common advice given to developers is Don't Repeat Yourself, the well-known DRY.

Followed by the sly tip Keep It Simple, Stupid; sweetened by the KISS acronym.

But, are they compatibles? Let's see 🧵👇
🏜️ Being DRY in programming is very good advice for a good reason:

When something changes, you only have to take care of the unique place where this feature is written.🦄

So is it not about code duplication or code reuse?
No, those are good consequences.
🤢 But, code duplication is a smell of code, isn't it?

Yes, and you should be concerned about any duplicates in your codebase.

Although don't rush to fix it.

Why?
Because chances are that you arrive with a wrong abstraction that it's worst than the initial duplication.
🍰 What could be wrong with an abstraction?
Software, even computers, is all about layers of abstraction!

Yes, but they come with a cost and need to be understood like a tradeoff. ⚖️
- 🏋️ Any indirection layer weighs as a complexity pound
- 🔐 Any reusable component might be caught by its dependents in a coupling trap

And these go totally against the sweet KISS principle.
🕺 Now I am caught in a trap, I can't walk out... says suspicious minds.

Not for long. You only have to take patience, breath, and count up to three.🧘
Most of the time the wrong abstraction comes from a very pernicious vice: Premature Optimization. 🤓

To rescue us there is another hero principle, enter YAGNI: You aren't gonna need it 😎
🧘 Basically, it tells you to wait for the problems before solving them.

It is a matter of time that duplication turns into triplication, but by then, you will have more knowledge and more reasons to pay for the abstraction.
So in summary:

- 🏜️ DRY is good advice but it comes at a cost.
- ⚖️ Load up on reasons and knowledge before creating abstractions.
- 🧸 Keeping your code simple is the ultimate demonstration of your talent.
- 💋 KISS a lot.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Alberto Basalo

Alberto Basalo Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @albertobasalo

15 Dec
🏷️ Naming is so important and so cumbersome in programming as Phil Karlton coined in his famous cite:

"There are only two hard things in Computer Science: cache invalidation and naming things."

A thread 🧵👇
📐From the design phase.
Having a common name glossary is the central point in methodologies like #DDD.
But even if you don´t follow it, you will appreciate having a #ubiquitous language to communicate with all the people involved.
🚧 In the architect's hands naming is the core of its work.
Creating #patterns is given a name to proven solutions. Using them is using those names.
Dividing codebases and defining #layers and #tiers forces you to give them a name.
Read 6 tweets
14 Dec
🏷️ Naming is so important and so cumbersome in programming as Phil Carlton coined in his famous cite:

"There are only two hard things in Computer Science: cache invalidation and naming things."
📐From the design phase.
Having a common name glossary is the central point in methodologies like #DDD.
But even if you don´t follow it, you will appreciate having a ubiquitous language to communicate with all the people involved.
🚧 In the architect's hands naming is the core of its work.
Using #patterns is given name to proven solutions.
Defining #layers and tiers forces you to give them a name.
Read 5 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(