Why You Should Make Your Code as Simple as Possible
Youâll program faster if you try to make your code simple, even repetitive, when you first write it

Programming is a lot like writing â you should start with a âbad first draftâ that solves the problem, then immediately edit it two or three times before you move on to the next problem.
Engineers scoff at being compared to measly âwritersâ â but who wrote the documentation that you used earlier today? And donât you âwrite code?â
Software developers have the luxury of working in the most creative type of engineering. After all, software engineers get to call a lot more shots when building an app than civil engineers do when building a bridge.
Working in a creative profession means that you can learn a great deal from writers whose words will never execute. And one of the best pieces of writing advice is something typically recommended to solve writerâs block.
Let me introduce you to the âbad first draftâ â because it will make you a much faster coder than ever before.
The âBad First Draftâ Method
The idea of a âbad first draftâ is so commonplace that youâve probably heard about it at some point in an English class even if youâve never gone down the rabbit hole of internet bloggers offering tips about writerâs block.
The idea of a âbad first draftâ is that you just need to finish the first draft even if it completely sucks â because any first draft is better than a blank page.
Editing your own work is easier than writing from scratch, so you need to try to write something (anything!), right now. Just make the code work.
To put it another way, would you rather have written 100 lines of bad code (that works) or zero lines of perfect code by lunch today?
Sure, at the end of the day, you may still end up with 50 lines of perfect code either way. But thereâs a psychological advantage to writing a âbad first draft:â youâll feel more successful with less stress.
Youâll write code and have fun doing it! What beats that?
How I Approach First Drafts
I prefer to think that I should aim to start with a âsimple first draftâ because a âbad first draftâ seems to carry a negative judgment about my abilities.
Do you want to be a âbad programmerâ writing âbad codeâ because you read a tip about writing a âbad first draftâ?
No, you want to be a âsuccessful programmerâ writing âgreat codeâ because you are following this tip about starting with a âsimple first draft.â
If youâve ever copied a code sample and then tweaked it for your own use, then youâve actually already done the âsimple first draft.â
When using a code sample, you inevitably change things quite a bit, but the key is to get it working first and then immediately improve upon it.
You can use the concept of a âsimple first draftâ to complete any programming task â whether youâre brand new to coding or already an expert.
Why the âSimple First Draftâ Works
When you write code that works, you feel successful, which puts you in a better mindset. Simple code is more likely to work the first time.
Plus, simple code is straightforward to write, saving you time. Yes, it may feel repetitious, and the clever part of your brain is going to be begging you for a âbetterâ solution with greater micro-performance in fewer lines of code.
Ignore it.
The trick is to sip a beverage when you get those feelings, then forge ahead in the pursuit of simplicity. Once the code works, youâre going to refactor it right away â and you can be as clever as you want once you have a working copy. But until you get there, keep things as simple as possible.
Writing coach August Birch calls this âleapfrog writing:â Write the whole thing, then edit it immediately. You alternate writing and editing.
Hereâs where programming differs from writing, though: Developers know when the first draft is âgood enoughâ because the code executes successfully. When your code works, thatâs your cue to immediately edit your âsimple first draft,â polishing it up a few times before you move on.
For anyone just learning to code, this approach improves two crucial skills: writing code that works, and improving existing code without breaking it.
A Code Example
I was recently mentoring a junior engineer via LinkedIn, and he was struggling with an overly-complicated coding challenge. While such coding challenges become less useful once you have real projects to work on, theyâre a great example of how to write a âsimple first draft.â
Since the problem was complicated, he tried to write a complicated solution. Letâs take a look at the challenge:
âWrite a function
addWeirdStuff
, which adds the sum of all the odd numbers inarrayTwo
to each element under 10 inarrayOne
.Similarly,
addWeirdStuff
should also add the sum of all the even numbers inarrayTwo
to those elements 10 or greater inarrayOne
.Bonus: If any element in
arrayTwo
is greater than 20, add 1 to every element inarrayOne
.â
Note that, just like in real life, he got incomplete instructions: The function addWeirdStuff
is supposed to return a new array containing the items from arrayOne
followed by the items from arrayTwo
.
He initially tried to solve it with a single for
loop, which was setting himself up for failure. Thatâs a complex cognitive task guaranteed to challenge your working memory, and he was getting nowhere with it.
This particular individual had contacted me previously for help with another coding challenge where heâd accidentally put the return statement into the body of a complex for
loop. Heâs not ready to write concise code just yet.
I told him that he needed to use two separate for
loops and that he should make them forâŠof
loops for simplicityâs sake. Hereâs the JavaScript code, including the tests he was given to check if the code works:

Itâs ugly, and it performs poorly, but it works! And itâs super-readable, especially for a brand-new coder struggling with basic concepts.
The next step is to polish up this âsimple first draft.â
Time to Refactor
Refactoring, love it or hate it, is better known to writers as the editing process. In both programming and other types of writing, editing is easier when youâve written the text yourself, especially when done right away.
Use simple language in order to reduce the complexity of the text at first, and then edit immediately. It works for all types of writing, including coding.
Taking our âsimple first draftâ from above, I refactored to the following:

This is still a challenging problem, and there are a ton of other ways to approach it, but this revision felt like a step in the right direction.
In this version of the first draft, I added the reducer pattern because I prefer to use functional programming techniques in my code.
Remember: âPerfect is the enemy of good.â This is just your first draft, and you can edit it again! Thatâs the leapfrogging process.
Iâm also prioritizing readability over performance since I now call .some()
inside each iteration of a loop. Thatâs a loop within a loop, for O(nÂČ) run-time. For small arrays, that wonât matter a bit, but it probably wonât get you that job at Google. Itâs also trivial to refactor out in my next edit of this first draft.
I made one more round of changes to add the .map()
method before I decided I was done with my âsimple first draft:â

Thatâs a âpolished first draft.â Iâve changed two forâŠof
loops to a .reduce()
, a .some()
, and a .map()
. I prefer this style of coding, but honestly, there was nothing âwrongâ with my very first draft â it worked, didnât it?
Now, this would be a great time to switch tasks and plan to review this particular code again tomorrow.
The Application to Real Code
In our real work, we often receive confusing instructions combined with deadline pressure, particularly when working with new APIs. Every coder wonders at times, âWhy doesnât this code work the way it should?â
For the student I was mentoring, he went from being unable to conceptualize a problem to solving it easily because he started with simple forâŠof
loops. Instead of feeling challenged and like a failure, he was left feeling successful and accomplished, all thanks to the âsimple first draft.â
If youâre more experienced, and writing .reduce()
the first time feels natural, go for it! But if you need to look up the syntax, see if you can do without it and then refactor to it later. In coding, you can always edit later.
Similarly, you will probably want to go back to add type checking if youâre working in JavaScript. For a coding challenge, thatâs not going to be necessary, but thatâs something to consider adding the next day.
The other real-world carryover of the âsimple first draftâ approach to coding is that youâll be making frequent git commits: at a minimum, you should commit each version of the first draft as youâre leapfrogging. You may have three or four working versions committed by the time youâve polished up the first draft.
Youâll appreciate having the commits if you find a bug when working on the code later because youâll have a few solutions to review in the repository.
Plus, making commits feels super productive to me, especially when Iâm working as part of a remote team. Thereâs that positive psychology again.
What About Testing?
Depending on your personal preferences for testing, itâs totally fine to write your tests before the code. Just follow the same approach: Write the simplest tests possible, and then refactor them as soon as they work.
Or, like most programmers, you probably prefer testing after you have a working piece of code â and thatâs totally fine. After you write your code and refactor it once or twice, write some simple tests, then refactor them.
The fastest way I know to write code is to do exactly the following:
- Write simple code
- Write simple tests
- Refactor simple code, using simple tests
- Refactor simple tests
Personally, I find that focusing on a âbad first draftâ (or a âsimple first draftâ as I like to say) makes me much more likely to write tests in the first place because Iâm not worried about writing perfect tests.
You might even consider testing to be creating a âsecond draftâ of your work and put off that task until tomorrow. Do whatever works for you, your project, and your organization â just donât forget about testing.
Conclusion
Whether youâre a code newbie, junior engineer, or expert, youâre going to write more code faster if you donât focus on perfection. Start with a âsimple first draftâ then immediately edit your code once it works.
Take it from a technical writer whoâs worked with 10 programming languages professionally and written 100,000 words about JavaScript in the last year â this writing tip works just as well for developers as for writers.
My genuine advice for programmers of all levels is that your first draft should be repetitious and even feel like a âhack.â Forget about coding principles like âDRYâ (Donât Repeat Yourself) at first, and stick with the most basic rule of coding:
âKISSâ (Keep It Simple, Stupid!)
You will be able to make your code beautiful once it works, but your whole day will be shot if you have to spend hours debugging â before you even get that piece of code to work even one time. Trust me, Iâve been there!
And, if youâre just learning a new programming language, development tool, or codebase, then this advice is mandatory, not optional.
Happy coding!