this post was submitted on 26 Nov 2023
711 points (89.3% liked)
Programmer Humor
19623 readers
6 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Those cases are rare. Often the most basic solution is good enough.
If you have to write complex code, then you should write a comment (write the name of the algorithm for example).
So you implement A* type of algorithms every day in your work?
My job title is actually a data scientist. I’ve seen few pieces of code that couldn’t have been made more explainable by just using a more clear and concise naming of variables and functions. Don’t try to be so overly clever with your single letter variables and Greek alphabet. Just explain what it is with a good name.
If I’m lucky I get to write a cool new algorithm once per quarter or so. Usually it’s just a standard algorithm that has an explanation in a Wikipedia page, so I just give the name of the algorithm and a link to that page.
Most of the time we’re just doing basic data processing building on the preexisting solutions. These generally don’t need comments.
The worst code is usually when someone has tried to be overly clever (including myself). Often a simple and straightforward solution had been overlooked. Simple solutions are easier to understand and maintain. Anyone can just look at the code and get a sense of what’s going on without any comments. In many cases a simple solution has also more accurate and faster to compute.
In my work, having explainable results far outweighs anything else, and you don’t get that by writing difficult to understand code.