Admit it… you have wondered if your peers think your code is readable and maintainable. Is your code earning you your colleague’s love or making them swear? Be honest for a second. In your mind, your code rocks and you secretly wish your peers could write code the way you do. Because if your peers write code the way you do, you would easily understand the code that they write and pass on to you for further development. Tip:"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live"Anonymous Have you ever felt like the code you are taking over is over-commented, the nested statements run deeper than the amazon jungle etc.? How awesome would it be if someone would bail you out in advance by writing code that is actually readable and maintainable?how_to_write_clean_code Are you writing readable and maintainable code? How can you tell if you are?

The hard truth: there is no magical way of knowing for sure

Quality is subjective, one person’s junk may be another one’s treasure. There aren’t any rules, no, but there are warning signs. Different organizations have different rules on coding but there are tell-tale signs that signal something is real good about this code.

1 Tell-tale: 30% to 40% of your code isn’t unnecessary comments.

You write a function that connects to the database using mysql_connect. You read a tutorial on PHP Data Objects (PDO) and you decide to try it. As a fall back, you simply comment the code that used mysql_connect. The same thing happens when you update other functions. Another common mistake is commenting the unnecessary. You have a function that says connectToDB and a comment that says this function connects to the database. Before you know it, 30% to 40% of the source code is comments. 1 Tell-tale sign: take time to browse through your code and remove the unnecessary comments.

2 Tell-tale: you do not have a coding convention

You are the lead developer and manage a team of developers. You want all the developers to easily understand each others code. How do you make this happen? Coding conventions is how you do it. Your organization should have a written coding convention that developers understand 2 Tell-tale sign: As you review your code after writing it, you ensure that it conforms the coding conventions of your organization.

3 Tell-tale: Your code has unit tests

Software version control rocks, one of the best practices is you only commit code that works. how do you know that the code works and does not break things that were already working? 3 Tell-tale sign: you write unit tests for your code and actually run them to ensure everything is OK before you commit the code.

4 Tell-tale: You do not have repetitive code doing the same thing

Software products basically have two major stakeholders, three actually if you count developers. The customer comes first. What matters the most to customers? Working solutions delivered within the shortest possible time. This is what actually causes many of us to simply copy and paste code. Secondly, the business. The goal is to make profit and one of the ways of doing this is reducing maintenance costs. Copying and pasting code increases the maintenance costs. This means you need to balance fulfilling the customer needs and those of the business. Take advantage of inheritance to write once and use many times. You will only have to update a single function. Third and not last, you as a developer will enjoy life if it’s easy to maintain the applications that you develop. 4 tell-tale sign: You avoid repetitive code, you use inheritance instead

5 Tell-tale: Your code uses exception handling for the unexpected

You have developed a great desktop application in C# and the client is so excited and starts using it. Once the client clicks on a button that prints the report, they get a message similar to the one below “Unhandled exception has occurred in your application. If you click Continue, the application will ignore this error...” Instead of the above message, lets’ say the above code was caused by a missing table in the database. You simply check the error code and if it corresponds with a missing table then you create the table on the fly and re-run the code. The user won’t even know things went south. At a minimum, you gracefully handle the exception and display an apologetic message to the user. 5 Tell-tale sign: your error handling code tries to intelligently fix what went wrong if it can else displays an apologetic error message to the user.

6 Tell-tale: Your code is consistence

Have you ever read code that had variable names like these?
String first_name;
String middleName;
String LastName;
… When you were expecting something like this
String first_name;
String middle_name;
String last_name;

private void setFirstName(String first_name) {
    this.first_name = first_name;

private void setMiddleName(String middle_name) {
    this.middle_name = middle_name;
6 tell-tale sign: You use consistent coding styles, all valuables have a similar naming convention, method names have unique naming convention etc.

7 Tell-tale: Your code is loosely coupled

Ever worked on a project that kept obsolete modules all because if you removed them then you would break what is working OK? Me too, I have worked with such code before. 7 Tell-tale sign: You ensure that the component dependencies in your application are at the least extent possible.

8 Tell-tale: Your code does not contain nests to the nth level where n is the highest number possible

The moment when you say it will only take a sec to implement feature x that the client requested for and you discover the code to be corrected looks like this
    private void processOrder(String setting, Integer value, Integer id) {
        if (setting == "a") {
            if (value > 1) {
                if (id == 0 && value < 10) {
                    //do some action and nest even more
        } else if (setting == "b") {
            if (value > 1) {
                if (id == 0 && value < 10) {
                    //do some action and nest even more
        } else {
            //do the default action
  8 Tell-tale sign: you do everything possible to avoid nested statements that extend to the nth level.

9 Tell-tale: Your file codes and files are organized

Your file structure looks like this POSApp --clsDBUtilities.cs --clsFunctions.cs --frmPOS.cs --frmProducts.cs -- ProductsDataSet.xsd … 9 Tell-tale sign: you directories structure look as follows POSApp --Classes ----clsDBUtilities.cs ----clsFunctions.cs --Forms ----frmPOS.cs ----frmProducts.cs --Datasets ---- ProductsDataSet.xsd

10 Tell-tale: Your code has white space for improved human readability

Your code uses a single line to separate logical sections of the code. This creates white space which has the benefit of improving the readability. 10 Tell-tale: you ensure that your code contains enough white space

11 Tell-tale: Code: You keep it simple stupid

Writing complex code and it works may feel good. Come back to it after 2 months and even you will swear at yourself. You actually decide to rewrite the whole thing other than figure out what the code does. Now imagine doing this to a violent psychopath who knows where you live. 11 Tell-tale sign: you avoid complex solutions and always find the simplest possible solution that works. This may actually take many times of code refactoring.

The bottom line

Writing great readable and maintainable code is not easy. I'd love to tell you that there are shortcuts but I won't, because we're being honest here, right?Writing readable and maintainable code requires work, commitment, determination, courage and the ability to go the extra mile. I know it’s tough and demands a lot from you but trust me, it’s worth it in the end. If you are willing to do that and take the first step in writing readable and maintainable code then there will always be a place for you in the programming community. You'll always stand out and be in demand.   Hurry up and get started now.