Code Ninja

The “Secret” Art of Clean Code

It shouldn’t be a secret, in fact I don’t want it to be a secret.

This so called “art” can define the future of your application, the sanity of your team, or worse, the future of your company.

Am I exaggerating ?

Not really. If you are a programmer with a few years of experience you’ve probably already seen this countless times, hell, you’ve probably done this already which is the so called messy, undocumented, untested and hard to read code.

Here’s a fictional story that I know lots of you can relate.

Meet Foo Inc.

The Foo Inc. company is about to release this new amazing app.

In the beginning everything was fine and dandy, the software appears to run, so the managers were happy. The developers know they could’ve do much better job than this but it’s to late to refactor, that would mean to create everything from scratch. Yes, they didn’t follow good development methodologies because they thought it was too boring and it wasn’t really that necessary.

And over time, their code is getting bigger, fattier, ugly and buggier, to the point that when a new change it’s needed a new bug pops out from some other place. So they quickly patch it, to get it over with it, and fingers are crossed.

So, the next time a new feature it’s added, they go back to that glue-patched-cryptic code and add more spaghetti code. At this stage some of them think it doesn’t even matter anymore, they just want to add that functionality to that beast and get the hell out.

Developers get demoralised, and eventually some of them quit. So the company has to replace them. They hire new people. But since this app code is uncommented, patched to the bones and cryptic, the new developers have hard time understanding it, so they talk to the managers and decide that they need to start over, a clean slate.

Now you can see where this is heading. There’s a new buzz in the company, and every developer wants to be part of this new “version”. It’s a breeze of fresh air, it’s like starting over. But it’s getting worse, because now they have two versions to maintain and nobody want’s to be part of the “old” code team.

So this company is spending more money, more resources into something that should be done right from the start if they enforced their developers into using good coding practices.

To some companies, this could be their end, the first version of the software could be so bad that they don’t have any more money to hire new developers or create a new version from scratch, because they got not clients for the fact that the first version had so many bugs that nobody bought it.

So…what’s clean code ?

Clean code it’s when you read it and you know the developer cared.
When it runs all the tests, it’s well documented, meaningful function, classes and variable names are used, it avoids code duplication. It’s when software methodologies are in place. In the end, clean code it’s when you learn how it works by just looking at it.

This is not something you learn from day one, it’s something your learn over the years. It requires practice and good taste, and this it’s why it’s called “Art”.

Explain to your team and your company why this is so important, why it’s important to use good coding practices and extend the deadline if needed in order to make your code better.

I’ve read this in the “Clean Code” book once:

Leave the campground cleaner than you found it

It really represents the Art Of Clean code mantra.

16 thoughts on “The “Secret” Art of Clean Code

  1. Permalink  ⋅ Reply

    Nono

    January 17, 2013 at 8:56am

    Nice post.

    As a developer, I’m often forced to produce dirty code because managers are always asking for functionalities done in a short time.

  2. Permalink  ⋅ Reply

    Robyn

    September 19, 2013 at 2:43am

    It’s difficult to find experienced people in this particular topic, but you sound like you know what you’re talking about! Thanks

  3. Permalink  ⋅ Reply

    Filomena

    September 29, 2013 at 7:10am

    It’s enormous that you are getting thoughts from this paragraph as well as from our discussion made here.

  4. Permalink  ⋅ Reply

    Mackenzie

    September 29, 2013 at 6:44pm

    Hello, Neat post. There’s a problem along with your site in internet explorer, might check this? IE still is the market chief and a good element of other people will miss your great writing due to this problem.

  5. Permalink  ⋅ Reply

    Ralph

    October 20, 2013 at 1:39am

    Thanks for a marvelous posting! I truly enjoyed reading it, you will be a great author.I will always bookmark your blog and will often come back sometime soon. I want to encourage yourself to continue your great writing, have a nice holiday weekend!

  6. Permalink  ⋅ Reply

    Hildegard

    October 20, 2013 at 5:39am

    Greetings from Colorado! I’m bored at work so I decided to check out your website on my iphone during lunch break. I enjoy the information you present here and can’t wait to take a look when I get home. I’m shocked at how quick your blog loaded on my phone .. I’m not even using WIFI, just 3G .. Anyhow, good blog!

  7. Permalink  ⋅ Reply

    Nannette

    October 20, 2013 at 9:39am

    Thanks a lot for sharing this with all folks you actually recognise what you’re speaking approximately! Bookmarked. Please also talk over with my website =). We could have a hyperlink trade agreement between us

  8. Permalink  ⋅ Reply

    Sadye

    October 20, 2013 at 1:39pm

    I know this site provides quality based content and other information, is there any other web site which offers these kinds of stuff in quality?

  9. Permalink  ⋅ Reply

    Vince

    October 20, 2013 at 5:39pm

    Tremendous issues here. I’m very glad to look your post. Thanks so much and I am looking forward to touch you. Will you please drop me a e-mail?

  10. Permalink  ⋅ Reply

    Marisol

    October 27, 2013 at 7:09pm

    For latest news you have to visit the web and on web I found this web site as a most excellent website for newest updates.

  11. Permalink  ⋅ Reply

    Addie

    October 28, 2013 at 4:16pm

    Paragraph writing is also a fun, if you be familiar with after that you can write or else it is difficult to write.

  12. Permalink  ⋅ Reply

    Letha

    October 31, 2013 at 3:48pm

    Hi there, its nice piece of writing concerning media print, we all be familiar with media is a impressive source of facts.

  13. Permalink  ⋅ Reply

    Tina

    November 3, 2013 at 1:17am

    What’s up it’s me, I am also visiting this site regularly, this site is in fact fastidious and the viewers are really sharing good thoughts.

  14. Permalink  ⋅ Reply

    Danny

    November 5, 2013 at 8:20pm

    It is not my first time to pay a visit this web page, i am browsing this website dailly and obtain pleasant facts from here all the time.

  15. Permalink  ⋅ Reply

    Danny

    November 12, 2013 at 1:20am

    If you are going for most excellent contents like myself, only visit this web site daily since it provides feature contents, thanks

  16. Permalink  ⋅ Reply

    www.gamezebo.com

    April 14, 2014 at 11:18am

    Great blog! Is your theme custom made or did you download it from somewhere?
    A design like yours with a few simple tweeks would really
    make my blog shine. Please let me know where you got your design.
    Cheers

Leave a Reply

Your email will not be published. Name and Email fields are required.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>