Clean Code for "Adult"
Tags: beginners, discuss, todayilearned
Published: 2020-04-27 18:59:10

🌙 Tonight, I decided to do nothing but reading. I just randomly went to some blogs and articles until I found one article written by Dan Abramov.

That article had spoken an immense wisdom to me. It was talking about Clean Code that maybe we can found it everywhere because everyone has been talking about Clean Code for a long time ago. 

But I found it's different. In that article, [Dan Abramov](https://twitter.com/dan_abramov) was looking at Clean Code from the "Adult" perspective. Based on one of his true experiences, he said that it took years to realize that he was looking at Clean Code from the "Child" perspective.

## The Story Began...
Once upon a time, Dan and his colleague are working on the same project. For more detail you can read the full article [here](https://overreacted.io/goodbye-clean-code/) because I just want to summarize the whole story.

Dan's colleague and the team had finished coding on some functionalities. And their code worked and everything was fine. But when Dan saw the code, he found that the code was repetitive or maybe he can just say that the code isn't clean.

Apparently, Dan has an Idea to make the code "Cleaner" from Dan's perspective at that time. Eventually, he did it. The code is half the total size and the duplication is gone completely. Which is good. It was more than enough to carry Dan to the very tight sleep because it was already late at night at that time. 😴

## The Next Morning...
The plot twisted. Dan's boss and the team politely asked Dan to revert the changes. Dan was aghast. Yeah, the code was a mess and Dan's code was clean! 😲

It took years for Dan to see they were right.

## 👶 Childish Mindset
Do you remember your reaction when you hear about Clean Code for the first time? Obsessed. Yeah, maybe that's a phase that many of us go through.

Yeah, just like a kid when Dad comes home and brings the coolest toy among his friends. The kid will always try to proudly show off his new to cool toy to his friends.

In the time that we acquired the Clean Code as our new superpower, we'll always try to implement it everywhere whenever we feel unconfident with our code. Just like a superhero that always wants to bring justice whenever he encounters bad things.

> “I’m the kind of person who writes clean code” 🦸‍♂️

## The Turning Point
Eventually, Dan realized that "refactoring" the code at that time was a disaster. There are two points :
- First, Dan didn't talk with the people who wrote the code he refactored. It destroys the trust between each other in the engineering team.
- Second, Dan's code traded the ability to change requirements for reduced duplication, and it was not a good trade.

## So, should we write dirty code instead? 
No. From this story, we could learn that we should think deeply before we could decide to do something. It's not only about "clean" or "dirty" code. Because clean code is not the goal.

In the real world, sometimes we need to shrink our ego, pride, or idealism down. Because we should consider seeing the problems from different perspectives.

## 🌱 Coding is a Long Journey
I believe that coding is a long long journey, when I saw my first line of code in my repository I posted about 3 years ago, I saw a lot of transformations in a lot of aspects in the term of coding.

The more I learned about concepts, paradigms, architecture, and also looking at problems from different perspectives, the more I realize that we should think more deeply before we could decide or use something.

## Conclusions
Remember the story about the kid I told you earlier in this article? Imagine that you are the kid in that story. And right now, you are not a kid anymore, you are an adult now, and you just realized that the toy given by your Dad is not just a toy.

Because you're looking at the gift from your Dad from a child's perspective you saw it like it's a toy. But when you see it from an adult's perspective finally you understand that it's a computer and you realize that you could build something amazing with it!. 👨‍💻

But, besides that, you should also realize that from another perspective, you could also do bad things that could harm the others with that computer.

So, in my opinion, it's about perspective. Don't let your understanding about Clean Code or other fancy things shackle you to see problems or solutions from different perspectives.

> Let clean code guide you. Then let it go. -- Dan Abramov