A comment on a previous HN thread really stuck with me: It is easier to write code than to read it.
With this in mind, what are the tips and tricks the wise and experienced HN have for writing code that is easier to read by others and and the future us?
Tips I have been told to date are to use easy to remember function and variable names, to write in a way such that the code documents itself (ie minimal comments), to use quite a few relevant comments (this contrasts with the previous tip), and so on.
I’d be very grateful for your thoughts on what works well for you in your professional environments, but also the “why” aspect - why do you think your approach, that I’m sure you have fine tuned over many years, is effective.
1. Don't try to be clever. Unless there's a really good tangible tradeoff, do things the boring way. Ideally try to avoid language-specific features just to save a few keystrokes
2. Write as much stateless code as possible. Use function parameters instead of class members. If this results in too many parameters, it might be a sign that the function is too bloated