DEV Community

Discussion on: Basic Software Architecture Principles (except SOLID)

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

To be honest, I actually make WET my philosophy: Write Everything Twice (Thrice, to be precise)

That is, I will copy-paste a bit of code exactly once; the third time I need it, that's the right moment to extract it.

The reason for this is a mix of a "just get it to work" mentality and being careful about adding abstractions too early.

Most experienced developers will probably remember a few instances where they thought they understood a problem and knew what to abstract, only to find out that they put a bit too much of the surrounding logic into the abstraction. When this happens, you either have to add ugly hacks to keep the interface intact, or refactor the abstraction and put some of its code back into the calling code.

The third time one needs a repeated chunk of code seems like a good trade-off to me: you've only copied it around once, and you've probably understood enough of what makes the similarity that you can come up with a good abstraction.

Collapse
 
the_unfactoring_guru profile image
The Unfactoring Guru

Exactly!!!