Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.

How do I learn to write clean code as a junior developer?

Tauseef Fayyaz

Answered by Tauseef Fayyaz

Asked 9 timesUpdated 28 Sept 2026
Short answer

Clean code is a set of habits, not a book you finish. Fix names, function size, flag arguments and error handling one habit at a time, let a formatter and linter settle style, learn to refactor in small steps behind tests, and keep a list of the review comments you get twice: that list is your personal curriculum.

What people tell me

I started my first developer job a few months ago. My code works and passes the tests, but every pull request comes back with a long list of comments: rename this, this function does too much, do not swallow this exception, this should be its own class. I fix them, but the next pull request gets similar comments. I read part of a clean code book, but I do not know how to turn it into habits, and I am worried my reviewers think I am slow to learn.

A composite of the messages behind this question, with personal details left out.

Key takeaways

  • Repeated review comments are a lesson you have not learnt yet, not a judgement of you; write them down.
  • Pick one habit a week, such as guard clauses or no flag arguments, and apply it everywhere you touch.
  • Let a formatter and linter handle style so reviews can focus on design.
  • Learn your IDE's rename and extract shortcuts; small safe refactorings are how clean code happens in real code bases.
  • Review your own diff before you ask anyone else to.

First, this is normal

Almost every junior developer I have worked with went through exactly this. Working code is the start of the job, not the end. Code is read far more often than it is written, and your reviewers are teaching you to write for the next reader. A long list of comments means people are investing in you.

The problem is not the comments. It is that you are fixing them one pull request at a time instead of turning them into habits.

Turn review comments into a checklist

Start a note today. Every time you get a review comment, write it down in your own words. When the same comment appears a second time, move it to a short pre-review checklist. Before you send any pull request, read your own diff against that list. Within a few weeks, most of those comments will stop, because you will be catching them yourself.

One habit a week

Books on clean code contain dozens of rules, and trying to apply all of them at once does not work. Pick one habit a week and apply it everywhere you touch:

  • Names that explain themselves: no data, info, temp or Manager. Rename with your IDE the moment you find a better word.
  • Small functions: if you need a comment to explain a block, extract it into a function with a good name.
  • No flag arguments: send(message, true) becomes two clearly named functions.
  • Guard clauses: handle invalid cases at the top and return early, so the main path is not nested.
  • Specific exceptions: never catch everything and carry on; catch only what you can handle and add context.
  • Comments that explain why, not what.

Let tools settle style

Formatting arguments waste everyone's time. Set up the formatter and linter your team uses, run them on save and make sure they pass before you push. Then reviews can focus on design, which is where you learn the most.

Learn to refactor safely

Clean code in real code bases comes from many small, safe changes, not rewrites. Learn your IDE's shortcuts for rename, extract function and inline, and run the tests after every step. Keep refactoring and behaviour changes in separate commits so reviewers can check both. The Gilded Rose refactoring kata is the best practice for this: do it once now and again in a month.

Where to learn it on Sefism

Send smaller pull requests

Finally, make your changes easier to review. A small pull request that does one thing, with a clear description of what and why, gets careful comments. A huge one gets tired ones. Smaller changes also mean fewer comments at once, which makes each one easier to learn from.

If you want a second pair of eyes on your code or your checklist, create a free account and book a session with me. You can also read more answers on the questions page.

Was this answer helpful?

Ask your own

Your situation is not quite this one?

Members get written answers to their own questions, a roadmap built for them and feedback on their projects. Early access is open: sign up and your account is active shortly after. Prefer to talk? A free call works too.

Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.

More questions people ask

All questions

AI is squeezing basic, repetitive freelance work first: plain data entry, simple transcription and translation, generic articles, basic logos and simple product descriptions. Work that combines a skill with judgement, client context or systems is holding up better, including automation, AI integration, analytics, specialist writing and full projects that own a business outcome.

Asked 14 timesRead the answer

It can be, but the maths has changed. Graduate tech jobs in the UK are harder to find, the Graduate visa drops from two years to 18 months for applications from 1 January 2027, and sponsored jobs have salary floors many junior roles miss. A UK master's is worth it if you want the degree itself, have a realistic plan for sponsorship, and can afford it without crushing debt.

Asked 14 timesRead the answer

Research a realistic range, avoid naming a number too early, let the employer make the first offer where you can, then counter once with a specific figure backed by your scope and the market. Look at the whole package, and for remote dollar roles compare the real take-home after fees, taxes and missing benefits.

Asked 13 timesRead the answer