When I was previously an instructor, one of the top questions I get is about what does good code look like and best practices. Programming in my opinion is a highly creative art form so there are multiple ways to express its intention. It is also dependent on the people you work with.
This article will go over programming philosophy rather than a universal way to magically write good code.
Art is expression with an intent
Code expresses an intention to two audiences (1) a fellow developer 🤓 and (2) a computer 🤖. It is a about communication and can take on different forms in a number of programming languages.
The top priority in writing code is clear communication to your fellow developer about what your code does and how the different parts come together. This is essential as we usually develop software in collaboration with other developers. If they cannot understand your code then they are unable to help contribute. This hinders creativity and productivity to build something awesome.
The second priority is writing code to effectively communicate to a computer. This means you are writing code that is working as intended and is efficient. Optimal is necessary for good user experience as no one likes clunky slow applications. However, optimal code is not always readable, so there needs to be a trade off here. As a developer you may have to find creative ways to optimize your code using other tools such as load balancing, caching or CDN (content distribution network).
This article didn't exactly tell you how to write "good code" as it is a general philosophy that needs to be tuned to people you work with. You'll find that from working with many different teams, you will also be using different programming practices. The most important thing is that you work well with a team.