Should you ask permission to write better code?
Tags: career, beginners, programming, bestpractice
Published: 2020-05-11 05:32:42

---
title: Should you ask permission to write better code?
published: true
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/rfkuwjb2tocpzk6kyhx3.png
description: some tips to start loving your code base and enjoy your job more
tags: #career, #beginners, #programming, #bestpractice
---

Many years ago, I started working on a project, **the code base was huge, developed by about 25 different developers over a span of 3 years.** 
The most recent parts were using a Dependency Injection framework, the older parts ( basically 70% of the entire code) were not.  
One day, [after I had finished my ticket in advance](https://dev.to/dvddpl/is-coding-a-sprint-or-a-marathon-e20), I was so pissed I had to waste so much time to achieve something trivial, that **I decided to create a branch and refactor the entire thing** to use that framework. 
It took me overall 2 or 3 days of work, split over many days of spare time ( whenever I had time after other tickets). Then I submitted the merge request to my Lead.
Expecting pat on shoulders and public appraisal.

![Applause!](https://media.giphy.com/media/ToMjGpvEPoYYu7Hzsys/giphy.gif)

Not really.  

**He was very very mad** at me because I did not ask and I used my time to work on something that had not been planned or estimated.

![I am mad!](https://media.giphy.com/media/qJmxeT1CY11pS/giphy.gif)

On the other hand, **he had a hard time hiding some satisfaction** - and relief - because I did - and rather quickly - a great job, which was bringing enormous benefits to the project and save lots of everyone's time ( and he knew that **the management back then would have never approved such refactoring** - that was actually quite hard to estimate)  

**Now I understand that that was a mistake.** I should have at least share my intentions with him and especially plan more carefully a dedicated QA session for it ( because I could have added some nasty hard to find bugs in areas of the code not affected by the current sprint  / planned feature).

![I was a bad boy](https://media.giphy.com/media/jyDNsJnUpdtFS/giphy.gif)

### Does it mean that you should not take the initiative of improving the code base you are working on?

Absolutely Not!

Some time ago I ended up on [this old post](https://dev.to/sandordargo/its-not-your-job-3m3d) here on DEV.to. which I really suggest.
As soon as I read: 

> They don't understand that if they write good code covered with meaningful tests they don't do a favor to their employer. They do a favor for themselves. They learn, they practice how to craft good code. The become more employable.

I commented immediately and then kept on thinking about it for the rest of the day.

Because that sentence is exactly what I tell often to some colleagues, who complain all the time because **their job is boring**, because **they mostly copy-paste similar code from other parts of the application** or add chunks of logic to other methods.

![bored at computer](https://media.giphy.com/media/ehnEyn4r2jdIRTXmJJ/giphy.gif)

### Do you like your job? 

> Some jobs suck, some workplaces suck, some projects suck, legacy code sucks most of the time. 

If you realized you don't like programming, you should look for something else - if you hate your boss and coworkers, well you should probably move on somewhere else.  If the problem is just the project or code you are working on, maybe there is something you can do rather than just complaining. 

> You have to find joy in what you do. And one way is to care and take ownership.

Of course I know there are boring projects and **ugly code bases** that make you want to pull your hair off. But in many cases, they **become ugly and messy because people do not put effort, care, love in them.** 

Without passion, without ownership, without [fighting against complexity](https://dev.to/dvddpl/strive-for-simplicity-2131) and entropy, the code base degrades over time: this time is a redundant chunk of code, the next time is a [typo](https://dev.to/dvddpl/check-that-spelling-please-code-review-chronicles-3pga), the next time a quick workaround and so on; until it does not matter anymore what you put in it. 
It's **the broken window theory**.  The more you find crap in your code base, the more crap you feel allowed to put in ( because, "ehi!,  what's the point in [change it](https://dev.to/dvddpl/it-s-working-why-change-it-code-review-chronicles-2on2) anyway")
 
And when it does not matter anymore if you are making it worse, how could you care and be passionate about what you do?

![this is important!](https://media.giphy.com/media/l4KhStvR6I0Hw0RmU/giphy.gif)


### But how can you not love what you do? you do it for 1/3 of your day!
I will repeat that again:

> You have to find joy in what you do. And one way is to care and take ownership.

**Empower yourself.** 
Do not wait for anybody else doing it for you.
Do not wait for somebody else to motivate you. 
Do not wait for anyone to let you work better or become better.

You have to do it yourself. You CAN do it yourself

### Does it mean I can refactor the codebase without asking anyone?

Speaking of Refactoring might be a bit dangerous or misleading. 
I often met some of those bored employees who embarked on **major refactorings that took ages and were not necessary at all.**
Those are bad, even when they are allowed.
With care about what you work on and "unallowed" refactoring, I mean small things, **details that just improve the code you found when working on it.**

> Always leave the code _you are editing_ better than you found it. (Robert C. Martin)

![Boy scout](https://dev-to-uploads.s3.amazonaws.com/i/sv2ohcwc09qdwifqdgxb.jpg)

The **boy scout rule** is a must for me (it could be fixing a typo, split a long method into smaller readable and unit-testable ones, etc), and adding a small unit test on everything I touch when bug fixing is another one.
The boy scout rule is the only way to fight daily against code entropy, and to some extent give more purpose to everything I commit. 

For these, you don't really need to ask for permission.  
Just do them, **it's part of your task**. 
And if you think, or are told that you are not allowed to write code that is _linted_ and unit-tested,  well then you should probably [rediscuss your team's "Definition of Done"](https://dev.to/dvddpl/please-be-professional-and-stop-saying-i-m-almost-done-n49) and reevaluate how your teams do the Estimates.

### You don´t need permission to be awesome

I am not, in any way, suggesting you go against your superior's will, because that could put you under a bad light, could cause a lack of trust and in some case - and I was very close - **you could even lose your job**.

But the inner motivation of being proactive, of doing always your best, and ultimately caring about what you work on is fundamental to love your job, have fun with it, and in the long run, it could positively impact your career.

![rebel](https://media.giphy.com/media/l2Sq5U6aeOCXDi6Zy/giphy.gif)

Therefore without becoming the new rebel in your team, just keep in mind this quotes from  [Grace Murray Hopper](https://en.wikiquote.org/wiki/Grace_Hopper):

> the most important piece of advice that I can give to all of you: if you've got a good idea, and it's a contribution, I want you to go ahead and DO IT. It is much easier to apologize than it is to get permission.

---
Photo by [bruce mars](https://unsplash.com/@brucemars?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on Unsplash