refactoring

7 ideas

Idiomatic code

Idiomatic refers to the most common way to write something in a language. Writing idiomatic code means following the conventions of the language, and solving problems the way they are meant to be solved in that language, not by porting programming patterns from other languages.

Idioms vary widely across languages.

4 STASHED

1 LIKE

Write Idiomatic Code

📖 Writing Idiomatic Python

3 IDEAS

DRY is not a silver bullet

"Don’t repeat yourself" (DRY) is usually good advice, but you have to get the abstractions right. Otherwise they quickly become unmaintainable.

Here's how it usually plays out:

  1. You write a cool abstraction
  2. Time passes
  3. A new requirement appears for which that abstraction is almost perfect
  4. Programmer B gets tasked to implement it. They feel honor-bound to retain the abstraction, so they alter the code to take a parameter, and then add logic to conditionally do the right thing based on the value of the parameter

Loop these steps a couple of times and you quickly get an unmaintainable mess.

2 STASHED

1 LIKE

The Wrong Abstraction

sandimetz.com

4 IDEAS