• Welcome to TalkativeTurtles - a community for developers & tech enthusiasts.
  • Share projects, get code reviewed, and talk tech without the noise.
  • New here? Introduce yourself in the Introductions forum!
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Title: Best practices for clean, readable code - what rules do you actually follow?
Threaded Mode
#1
Wanted to add one that I think is underrated: deleting code is one of the best things you can do.

Every line of code is a liability - it has to be read, understood, maintained, and tested. Code that doesn't exist has no bugs. The most impactful refactoring sessions I've had were ones where I removed several hundred lines that were no longer needed or could be replaced with a library call or a simpler approach.

A corollary: the right response to "we might need this later" is almost always to delete it and recreate it if the need actually arises. YAGNI (You Aren't Gonna Need It) is underrated as a principle.

Also: prefer boring code. The cleverest solution is often the hardest to maintain. If you find yourself proud of how clever a piece of code is, that's often a warning sign.
Reply
#2
Clean code is one of those topics everyone has opinions on but nobody fully agrees on. Some people swear by Uncle Bob, others think a lot of it is overengineered nonsense for solo projects.

Here are the principles I genuinely apply day-to-day:

Names over comments. If you need a comment to explain what a variable or function does, the name is wrong. getUsersWithExpiredSubscriptions() beats getUsers() with a three-line comment every time.

Functions do one thing. If you have to use "and" to describe what a function does, split it. This also makes unit testing trivial.

Short functions, not long ones. I aim for under 20 lines. If it's longer I ask what I can extract.

Avoid double negatives. if (!isNotAdmin) is a brain teaser. if (isAdmin) isn't.

Consistent formatting is non-negotiable. Pick a linter, commit the config, and never argue about tabs vs spaces again.

What are the rules you actually follow? And are there any "best practices" you think are cargo cult nonsense in the real world?
Reply
  


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Rules] Programming & Development — Forum Rules Zero Two 0 170 06-21-2026, 09:34 AM
Last Post: Zero Two

Forum Jump:


Browsing: 1 Guest(s)