Comment

Comment by InclinedPlane

I've been reading other devs code for about two decades now. Universally all the code I see is not quite up to the standards I have for "good code" though some of it is better than others. Most devs give up on getting better writing code too easily, or more importantly they focus on the wrong things. There is always room for improvement no matter how good you are.

Focus on making your code clearer, not fancier or "faster". Don't prematurely optimize your code by eye. Generally just being conscious of the major performance no-nos to avoid and being able to use appropriate tools (like a profiler) when and if you actually need to tune performance is all you need. Instead concentrate on making your code highly readable, self-documenting plus fully documented (the best of both worlds!), as well as composable and maintainable and you'll be well set. Not just will you make other developers happy and improve the code base overall (fewer bugs, easier modifications for inevitable feature changes in the future) but you'll make your future self happier when you have to come back to that code.

By far the biggest mistake I see developers make is making their method/function bodies too long. Extract your methods people, it's not that hard and it's a great habit to get into. It takes skill to get good at it but a decently named small function makes code more readable and more reliable. And getting into the habit of making little functions that just take a few inputs, do stuff, and return a value makes your code way easier to unit test as well.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton