DEV Community

Discussion on: Keep your code dumb

Collapse
 
ssteinerx profile image
Steve Steiner

Being the "old guy" on most projects, often I run into a piece of code written in the latest "clever" style. If I can't just read through it and explain to myself what it does, I see if I can get the person who wrote, or at least someone who thinks they can understand it, it to explain to me, in simple terms, exactly what it does.

I open a code editor, and write their explanation down, in code. Very simple code.

By the end, I understand what it does, they understand what it does, the version we've just written will usually serve as a drop-in replacement and, most importantly, they usually "get" why I write code that's so simple and not clever at all.

And, for major bonus points, when the bug is hidden in (dare I say "created by"?) the clever, it pops right out and gets solved in the course of the "simple" rewrite.

Collapse
 
joelnet profile image
JavaScript Joel

Totally agree!

If you have to break open up a function (or any code) to understand what it does, there is something wrong with the function.

Collapse
 
sergsoares_15 profile image
Sergio Soares

Great method, i will try practice as soon as possible. Thanks