I want to improve my code quality, how can I train to achieve this?

I want to write good code.

Good as in:

  • high quality code, which passes any code review
  • respecting idiomatic soft rules
  • respecting the conventions & norms of the repo I am contributing to
  • passing most linters: like all error results should be checked, unused public fields should be private, etc

How can I train to improve my code quality ? Any suggestions ? It is a skill like any other, but so far I could not come up with a way to train this skill specifically.

Find things you like, use them, hate them, make new ones.

Actually I am reading this book:
Clean Code: A Handbook of Agile Software Craftsmanship


1 Like

Great book, however I need something more practical, and focused on Golang.

That’s a good and important question, and I think there is no easy answer, but here are some thoughts.

  • Respecting language idioms and project conventions requires that you have all those idioms and conventions at hand. Yes, that means learning them by heart, but this does not need to happen all at once.
  • Passing linter checks can be achieved by, well, running linters on your code and adjusting the code as required. This is a technical problem with a technical solution. No one expects that your code is perfect on the very first linter run.
  • The remaining two bullet points, SOLID and high-quality code, are certainly the toughest ones. I guess you cannot take shortcuts here but have to
    • read a lot of other people’s code, ideally that others already have reviewed and tagged as high- or low-quality (and provided reasons for their judgement).
    • write a lot of code and have it reviewed by experienced devs. Don’t be embarrassed by bad code that you wrote, you can always refactor it.
    • learn to write good tests. Quality is measured in numbers of bugs and robustness in the face of rare edge cases, so if you know how to test your code well, you know how to maintain quality.

There are many ways you can improve your coding skills:

Get some practice by working through the exercises. The exercises are designed to help you develop a range of skills, so if you’re stuck on one exercise it might be worth doing another one first.

Read lots of code! You’ll find that by reading and writing lots of code, you’ll learn more than from any one tutorial or book.

Study other people’s code! There are many websites that let you see how professional developers write their code.

1 Like

hi @sandersbud4

Can you post a link to these exercises ? I think some katas, or refactoring problems, that have the option to check your solution against an ideal one, would be awesome.

Where can I find such exercises ?

Where can I find these exercises??

For Go-focused content you can check:

1 Like

Sir, this is a Golang forum.

Sorry for the late reply. I was a bit busy. Anyhow, I will recommend you guys to explore the following sites.

  1. LeetCoder
  2. Programmer
  3. CodinGame
  4. Project Euler

Hi @sandersbud4

These coding websites are nice, but they help mostly with algorithms, not with code quality directly. Do you have any advice on how to use them, in order to improve code quality ?

Thank you all for all these useful resources !

Hi, I have little effort to answer your question.

  1. Embrace coding conventions. Development teams usually create a list of guidelines known as coding conventions.
  2. Use a code linter.
  3. Adopt continuous integration.
  4. Leave helpful comments.
    For more answer also see https://forum.golangbridge.org/t/i-want-to-improve-my-code-quality-estrazioni10elotto


I will be as practical as possible and give you some ideas that you can accomplish in the short term of period if you are practical and curious to know more!

1 Like

Hi everyone :star_struck:

I am totally agree with you my confusion is clear. I am very happy i am bookmark this thread I want to improve my code quality, how can I train to achieve this? - #17 by MrWormHole.

Have a good day to all the members :blush: