Advice for Junior Developers
Tags: beginners, productivity, codenewbie, learning
Published: 2022-10-11 12:11:33

---
title: Advice for Junior Developers
published: true
description: Over the 15+ years of my development career, I have learned several things that significantly increase my effectiveness. In this post, I share those learnings with you.
tags: Beginners, Productivity, CodeNewbie, Learning
cover_image: https://www.entropywins.wtf/blog/wp-content/uploads/2022/09/code.jpg
# Use a ratio of 100:42 for best results.
---

Over the 15+ years of my development career, I have learned several things that significantly increase my effectiveness. In this post, I share those learnings with you.

Structure:

* Foundational Advice -- Important context and motivation for what follows
* Technical Advice -- The main course
* Recommended Reading -- Links to high-quality books and blogs that are great for getting started

This blog post mentions and links valuable concepts that you can explore further as you see fit.

<h2>Foundational Advice for Juniors</h2>
<h3>1. Code is not the Point</h3>
As developers, we like writing code. Most of us want to be given a nice unambiguous task. A fun technical puzzle to solve without paying attention to the rest of the world.

Put reasonable effort into making sure that you are solving the right problem. To quote Peter Drucker: <a href="https://medium.com/swlh/there-is-nothing-so-useless-as-doing-efficiently-something-that-should-not-have-been-done-at-all-8c5d2282319d">There is nothing so useless as doing efficiently that which should not be done at all</a>. Gather feedback early and often, typically by continuous delivery to real users. <a href="https://agilemanifesto.org/">Be</a> <a href="https://agilemanifesto.org/principles.html">Agile</a>.

Software development is expensive, with the vast majority of the effort of real-world projects typically going into maintenance. Combine this with the goal being user/business outcomes, <a href="https://blog.codinghorror.com/the-best-code-is-no-code-at-all/">the best code is often no code</a>. To quote Bill Gates: "Measuring programming progress by lines of code is like measuring aircraft building progress by weight."

See also: <a href="https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it">YAGNI</a>, <a href="https://en.wikipedia.org/wiki/KISS_principle">KISS</a>, <a href="https://blog.codinghorror.com/the-last-responsible-moment/">The Last Responsible Moment</a>.
<h3>2. Software Design Matters</h3>
During the first 5 years of my development career, I thought that software design is for software architects or other people with special roles. I was focused on "getting things done", and saw software design and practices such as writing tests, as a distraction at best. My code worked, and I was getting a lot of things done. Or so I thought.

Then I read <a href="https://www.goodreads.com/book/show/3735293-clean-code">Clean Code</a>, by <a href="https://cleancoders.com/">Robert C. Martin</a>. This book motivates caring about software design and contains examples and many technical heuristics. The central takeaway of the book is: "<strong>The only way to go fast is to go well</strong>". In other words, <a href="https://martinfowler.com/articles/is-quality-worth-cost.html">if you make a mess, it will slow you down</a>. See also: <a href="https://martinfowler.com/bliki/TradableQualityHypothesis.html">TradableQualityHypothesis</a>, <a href="https://martinfowler.com/bliki/DesignStaminaHypothesis.html">DesignStaminaHypothesis</a>

Learning how to write well-designed clean code of course takes time and effort. And when you start, you will be slower and make mistakes. <a href="https://www.entropywins.wtf/blog/2017/01/02/simple-is-not-easy/">Simple is not Easy</a>.
<h3>3. Use the BEST Practices</h3>
Writing tests tends to be beneficial. There are exceptions, but most of the time, it makes a lot of sense to write automated tests. Writing tests is an example of a best practice.

If you are new to writing tests, just follow the best practice and write tests for everything. <strong>When starting, blindly following the best practice will be better than following your own underdeveloped judgment</strong>. Over time you will learn how to write tests effectively, and be able to tell the difference between you have messed up, and situations where writing a test is not worth it. You will also start to understand the value tests bring on a more visceral level, by having experienced the decrease in debugging sessions and the worry-free refactoring enabled by your tests. <strong>After developing your judgment, you will be able to transcend the best practice</strong>.

This advice applies to best practices in any area that you are a junior in. Automated tests are just an example.

One big gotcha is that it is not easy to tell the difference between a sensible best practice and something nonsensical or even counterproductive. This is made more complicated by most existing code being a mess, and by most developers, including "experienced" and "senior" ones, not knowing software design basics. This makes having a good mentor extremely valuable. Barring that, one piece of advice based on my own experiences is to be wary of best practices specific to the community of your language or framework. Look for evergreen advice that has been around for decades.
<h2>Technical Advice for Juniors</h2>
Our focus will be on technical topics. Many other areas are important, such as health, happiness, career, and soft skills. Knowing how to avoid a technical pitfall won't help you if you are sleep deprived and working on the wrong problem for a toxic boss that underpays you.
<h3>4. Write Tests</h3>
Write automated tests. Perhaps write tests before the code, such as via <a href="https://en.wikipedia.org/wiki/Test-driven_development">Test Driven Development</a> (TDD). This makes it easy to verify your code is correct in a repeatable manner, thus saving you from much manual retresting and from debugging sessions.
<blockquote>You think test-first is difficult? Try debug-after.</blockquote>
Perhaps even more importantly, tests give you the safety net to refactor your code. And continuous refactoring is needed to keep your code clean. Without a reliable test suite, it is all the more likely that your code will rot.

Writing tests is difficult if the design of your code is poor, such as when using inheritance for code reuse, or when using static functions. If on the other hand, you have <a href="https://en.wikipedia.org/wiki/SOLID">SOLID</a> classes, with no global dependencies, then writing nice tests is not so difficult.

Test design matters because poorly written tests will slow you down. Avoid binding your tests to implementation details of the code under test or to the structure of the system. Avoid overusing Mocks and <a href="https://www.entropywins.wtf/blog/2016/05/13/5-ways-to-write-better-mocks/">write better Test Doubles</a>.
<h3>5. Do Not Use Inheritance For Code Reuse</h3>
This is one of those best practices that bring to mind the "Use the Best Practices" section. My advice: do not use inheritance for code reuse at all when you are starting out. It is rarely the right call and can do a lot of harm. <a href="https://en.wikipedia.org/wiki/Composition_over_inheritance">Favor composition over inheritance</a>.
<h3>6. Write Object-Oriented code</h3>
Write <a href="https://en.wikipedia.org/wiki/SOLID">SOLID</a> code that is not <a href="https://williamdurand.fr/2013/07/30/from-stupid-to-solid-code/">STUPID</a>. There is so much value in understanding these principles and anti-patterns.

Actually create objects. Classes with only static methods are not OO. Try to avoid using static code altogether.

See also: <a href="https://www.entropywins.wtf/blog/2017/02/17/why-every-single-argument-of-dan-north-is-wrong/">my defense of SOLID</a>.
<h3>7. Write Functional Code</h3>
(<a href="https://en.wikipedia.org/wiki/Functional_programming">Functional programming</a> is not to be confused with <a href="https://en.wikipedia.org/wiki/Imperative_programming">imperative</a> <a href="https://en.wikipedia.org/wiki/Structured_programming">structural programming</a>.)

This point is not about fully switching to a functional language. You can benefit from using a functional style in your OO language. <a href="https://www.entropywins.wtf/blog/2018/10/24/readable-functions-minimize-state/">Minimize state</a>, especially mutable state, and <a href="https://www.entropywins.wtf/blog/2018/10/30/readable-functions-do-one-thing/">do one thing in your functions</a>. See also: <a href="https://www.destroyallsoftware.com/screencasts/catalog/functional-core-imperative-shell">functional core, imperative shell</a>.
<h3>8. Use Informed Duplication</h3>
Copy-pasting big chunks of code to multiple places is almost always unwise. Any self-respecting developer soon learns this and starts to follow some form of <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">Don't Repeat Yourself</a> (DRY). Unfortunately, the well-intended pursuit of DRY often leads to overengineering and accidental complexity. This is where the counterpart of DRY comes in: Write Everything Twice (WET). The idea behind WET is to only deduplicate on the third occurrence of duplication.

For a more in-depth look at the costs and benefits of deduplication, see <a href="https://www.entropywins.wtf/blog/2017/09/06/the-fallacy-of-dry/">The Fallacy of DRY</a>.
<h3>9. Types, Names and Comments</h3>
Try to write self-documenting code and avoid comments.
<blockquote>Every time you write a comment, you should grimace and feel the failure of your ability of expression. -- Robert C. Martin</blockquote>
Comments are dangerous because they can lie. The code can change without the comment being updated. New code can be added right under the comment. The comment might have been wrong or inaccurate in the first place. When this happens, the comment not only becomes useless, it becomes misleading.

To write self-documenting code:
<ul>
 	<li><a href="https://www.entropywins.wtf/blog/2018/10/30/readable-functions-do-one-thing/">Do one thing in your functions</a>
<ul>
 	<li>By doing a single thing in a function, you can give it a clear name</li>
 	<li>Feel the need to explain what different sections of your function do by adding comments? Instead, extract each section into its own well-named function.</li>
 	<li>"<a href="https://verraes.net/2013/09/extract-till-you-drop/">Extract till you drop</a>": if you can meaningfully extract a function, then you probably should. Don't be afraid of small functions.</li>
 	<li><a href="https://martinfowler.com/bliki/CommandQuerySeparation.html">Command Query Separation</a></li>
 	<li>Similar to the <a href="https://en.wikipedia.org/wiki/Single-responsibility_principle">Single Responsibility Principle</a> for classes (The S in SOLID)</li>
</ul>
</li>
 	<li><a href="https://www.entropywins.wtf/blog/2018/10/24/readable-functions-minimize-state/"><strong>Minimize state</strong></a></li>
 	<li><strong>Use types</strong>. Combined with a test suite that executes the code, you can rely on the types telling the truth.</li>
 	<li><strong>Avoid mixed types</strong>. Avoid parameters or return values that can be an integer, a boolean, or a string. This naturally happens if you write focused functions that only do one thing.</li>
 	<li><strong>Write tests</strong>. A well-written and comprehensive test suite shows you how the production code can be used, and how it behaves.</li>
</ul>

<p>
<a href="https://www.goodreads.com/book/show/3735293-clean-code">Clean Code</a> by Robert C. Martin has some good rules of thumb about naming and comments.
</p>

<h2>Recommended Reading for Juniors</h2>
<h3>Books</h3>
<ul>
 	<li><strong><a href="https://www.goodreads.com/book/show/3735293-clean-code">Clean Code</a>, 2007 book by Robert C. Martin</strong></li>
 	<li><strong><a href="https://www.goodreads.com/book/show/5608045-apprenticeship-patterns">Apprenticeship Patterns: Guidance for the Aspiring Software Craftsman</a>, 2009 book</strong></li>
 	<li><a href="https://www.goodreads.com/book/show/44919.Working_Effectively_with_Legacy_Code">Working Effectively with Legacy Code</a>, 2004 book by Michael Feathers</li>
 	<li><a href="https://www.goodreads.com/book/show/44936.Refactoring">Refactoring: Improving the Design of Existing Code</a>, 1999 book</li>
 	<li><a href="https://www.goodreads.com/book/show/23215733-the-software-craftsman">The Software Craftsman</a>, 2014 book</li>
</ul>
<h3>Blogs</h3>
<ul>
 	<li><a href="https://martinfowler.com/">MartinFowler.com</a> - Tons of high-quality articles about all things software development</li>
 	<li><a href="https://www.entropywins.wtf">EntropyWins.wtf</a> - Clearly the best blog on the internet :)</li>
</ul>
See also: <a href="https://blog.codinghorror.com/recommended-reading-for-developers/">Recommended Reading for Developers</a> by Jeff Atwood
<h2>Bonus links</h2>
<ul>
 	<li><a href="https://martinfowler.com/bliki/TellDontAsk.html">Tell Don't Ask</a> -- Encapsulation best practice</li>
 	<li><a href="https://wiki.c2.com/?LawOfDemeter">Law of Demeter</a> -- Coupling best practice</li>
 	<li><a href="https://en.wikipedia.org/wiki/Domain-driven_design">Domain Driven Design</a> -- A sizeable toolbox. More advanced, good to first learn the basics.</li>
 	<li><a href="https://williamdurand.fr/2013/06/03/object-calisthenics/">Object Calisthenics</a> -- Rules that restrict what you can do in programming. Nice for learning how to do things differently</li>
 	<li><a href="https://en.wikipedia.org/wiki/Pair_programming">Pair Programming</a> -- A great way to learn from each other</li>
 	<li><a href="https://codingdojo.org/kata/">Code katas</a> -- Simple programming, great for practicing a specific technique or skill such as Test Driven Development</li>
</ul>

<h2>About Jeroen</h2>

<a href="https://www.entropywins.wtf/">Jeroen De Dauw</a> is CEO of <a href="https://professional.wiki/">Professional Wiki</a>, which provides <a href="https://www.pro.wiki/">wiki hosting</a> services. He occasionally writes on his <a href="https://www.entropywins.wtf/blog/">software design blog</a>. You can <a href="https://twitter.com/JeroenDeDauw">follow Jeroen on Twitter</a>.