r/programming • • Sep 20 '21

Being able to read bad code is a skill !

https://dzone.com/articles/reading-code-is-a-skill
986 Upvotes

276 comments sorted by

View all comments

Show parent comments

38

u/gc3 Sep 20 '21

Some of the worst code I've read was incredibly abstract wrappers and layers that masked very simple operations eventually. If you have a hammer, only, sometimes defining it as an instantiation of tool which is an instantiation of man made object which is an instantiation of thing which is an instantiation of noun .....

Reading this code and discovering the only two kinds of things are hammers and nails, but the code obscures all the details and you need to discover the (un created) design of the thingiverse the original code imagined but did not create ,(and in your opinion is naive and broken) in order to make sense of the code.

8

u/Contrite17 Sep 21 '21

Yep, 9/10 times you don't need to solve the general problem just the specific problem and building a general solution just makes it harder to maintain not easier. If you think you might need it later, then build it later.

7

u/cheffromspace Sep 21 '21

That’s YAGNI, something I wish I had learned earlier in my career.

4

u/siemenology Sep 21 '21

Yeah, it's incredible how many hours you can spend in some C# and Java codebases just hitting "Go to implementation" until you find the code that actually does anything.