Sunday 7 July 2013

Does Clean Code matters ?

Does Clean Code matters ?

YES,
And the other question is WHAT FOR ? That's what we talk about here..

OK lets go for it..
What is Clean code ? Actually we don't have the exact definition for this. But there are some definitions that create by geniuses. Below are some of these...


Bjarne Stroustrup, Inventor C++ and author of The C++ Programming Language
 I like my code to be elegant and efficient. The logic should be straightforward to make it hard  
 for bugs to hide, the dependencies minimal to ease maintenance, error handling complete  
 according to an articulated strategy, and performance close to optimal so as not to tempt  
 people to make the code messy with unprincipled optimizations. Clean code does one thing  
 well.  

Dave Thomas, founder of OTI, godfather of the Eclipse strategy,
 Clean code can be read, and enhanced by a developer other than its original author. It has  
 unit and acceptance tests. It has meaningful names. It provides one way rather than many  
 ways for doing one thing. It has minimal dependencies, which are explicitly defined, and provides a clear and minimal API. Code should be literate since depending on the language, not all necessary information can be expressed clearly in code alone.  

Michael Feathers, author of working Effectively with Legacy Code,
 I could list all of the qualities that I notice in clean code, but there is one overarching quality that leads to all of them. Clean code always looks like it was written by someone who cares. There is nothing obvious that you can do to make it better. All of those things were thought  
 about by the code’s author, and if you try to imagine improvements, you’re led back to  
 where you are, sitting in appreciation of the code someone left for you—code left by someone  
 who cares deeply about the craft.  

  WHY WE NEED CLEAN CODE ?
If your a programmer with more than one year you know what I mean..

First take a look at bad code or a mess code.
 

Suppose you get a new requirement and you need to add the new functionality to your existing code which is really bad and messy. Before adding any new thing to your code first you need to understand the exiting code. That means you need to READABILITY your existing code. Since its a bad code you will go through really pain full time to understand what the code says. For example imaging a code with no comments, no meaning full variables, no meaning full function definitions with hell of big line of codes that does too many things within single code block , this will drive you crazy.
So this will take more than time than your expecting(Or your PM) to read and understand only others code. Every programmer knows about the damn dead lines and our heads will bump up.
If it is a clean code it must full fill the READABILITY.

That's one of the basic thing that each and every code must have. But there are more. Formatting, Unit testing, avoid writing bad comments, Error handling  are some of. So will talk about all of these things in near future.

No comments:

Post a Comment