When I was an instructor, I would often receive questions about how to know what does good code looks like. In my opinion, programming is a highly creative art form so there are multiple ways to write good code. Quantifying good code will often be dependent on the people you work with and the practices your team follows.
In general, I believe in good programming philosophies rather than dogmatic ways to write good code.
Here are some philosophies I like to keep in mind --
Art is expression with an intent
Code expresses an intention to two audiences -- (1) a fellow developer 👩💻👨💻 and (2) a computer 🤖💻. It is about communication and can take on different forms in different programming languages. It can also take on different forms between different audiences!
A primary priority in writing code is communicating clearly to your fellow developers about what your code does and how the different parts fit together. This is essential, as we usually develop software in collaboration with other developers. If others cannot understand your code, then they are unable to help contribute. This hinders creativity and productivity in building something awesome.
A secondary 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 performance is necessary for good user experience because no one likes slow applications. However, optimally-performant 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 without making your code more difficult to read. Using other tools such as load balancing, caching, or CDNs might help with this.
I'm sorry if I didn't tell you how to write "good code" as it is something that needs to be defined with and tuned to the people you work with. You'll find that from working with many different teams, you will run into different programming practices and styles. The most important thing is to write code that communicates well...to people!