(Pic: Broken Bridge on Flickr)

You will write ‘bad code’.

(And it’s okay.)

By no means am I saying you should neglect the effects of bad code in production — It also hurts me facing code that is far from ideal, but I finally understand that bad code is something essential in a developer’s pathway.

Perhaps you still remember when you first rode a bike. You probably fell down a few metres ahead. Falling, though, didn’t diminish your achievement. We, humans, are constantly making mistakes. We all miss something, sometime — or most of the things, most of the time.

Programming is no different from that. Remember your first simple application? I bet it felt great. Or the first time you tried Ember and were amazed by it?

Now, think about your code from a few years ago. Or even months. You think it is perfect? Hint: it isn’t. Our early pieces of code are mostly spaghetti code from tutorials and docs! Little to none documentation. Hours and hours of struggle to get simple logics working.

A screenshot of an early 2011 (6 months of coding) Tech social network I was building in PHP

To be honest, it’s not much of a difference from now. Even if you use Composer, a hipster database and serve an OAuth2.0 compliant RESTful API or whatever buzzword you may add — you still write bad code. Why? Because you’re learning. Every time you pick up a new tool, framework, library, you will write code that isn’t the best. And you will learn from it. Bad code educates us to be better developers.

Keep learning new things, and write bad code!

I’m among those people who love new libraries. It is awesome playing with them. Understanding what happens behind the scenes and creating throw away projects is so much fun! The code that I write for them, though, is far from great. It is terrible. Usually a mix of different tutorials, tweaked and twisted to my own liking.

That is not the kind of code that should go into production, but is definitely important to your path as a developer. The bad code you wrote has probably taught you something new. My first NodeJS project has awful code. It taught me so much, though, that I’m currently a JS developer!

Learning new things is hard enough by itself. You can’t learn how to drive thinking about how you would drive in a F1 race. Forget abstractions, duplicated methods, coding style and all of that, at least for now, focus on learning and have fun!

Be conscious about how bad your code is,

learn from it and improve it!

Don’t let bad code drag you down. Knowing you’re writing bad code is a great step to improve yourself as a developer. It shows you want to improve. It shows that you’re learning and growing.

If you look at your older code and already know how to write better versions of it, be utterly happy - You have improved!

If not, perhaps you haven’t exposed yourself to it enough. Learning is not a spontaneous achievement, but a gradual process instead. It is okay to have spaghetti code, if you spend time on understanding it. Over time, you will understand the underlying structure of things. You will understand the what and then the why of the things you developed. The more you try, the more you fail, the more you learn!

“Good code” will eventually come

But there will always be bad code before it!

Development is like a college where you never graduate and the curriculum keeps changing. You will fail, you will succeed, but you will learn in the process. Be confident, be self-conscious and never settle for what you already know.

Be ready for change, keep going and do your best — you got this!

— J. Lucas Lucchetta

If you liked this, share it with and stay tuned for more posts focused on web development, UI and UX. Follow me on Twitter (@joaolucasluc) and here on Medium, and don’t hesitate to hit me up with feedback or questions!