Do you know that most of the time of software development is spent on reading?

While the effective aim of writing code might be to get working software, so to just write the code that works, it is important to write code that is clean, Especially for dot net developers as the code they write could involve other people and be reused, maintained for much time after it is written.

Before I go on to explain what i mean by clean code and why its important, let me show you a small example:

This is a simple console .NET application that prints hello world

See this code –

using System;

namespace myApp

{

    class Program

    {

        static void Main(string[] args)

        {

            Console.WriteLine(“Hello World!”);

        }

    }

}

Now see and try to understand this code:

using System;namespace m{class P{static void Main(string[] args){Console.WriteLine(“Hello World!”);}}}    

Which code did you find more comfortable to read? Imagine if all the complex code for an application would be written like this!

For a computer it’s all the same whether it’s written in style 1 or 2 and does the same thing, but for people, it makes a huge difference.

This is the most important aspect of the clean code — it improves readability! 

With have a basic understanding of why clean code is important, let us see some more reasons as to why to write clean code:

Enables efficient development from the start:

Several suggestions for writing clean code involve some of the best practices in programming which not only makes your code clear and readable but also efficient in its approach to create functionality and solve problems. So, if you follow all the principles of clean code, you would inherently apply and get used to a myriad of best practices in programming which would make you an efficient dot net developer!

Easier to debug:

There would be many times your code does not work as you expect it to do and all the workings of the code need to be analyzed to see where it went wrong. When your code is clean with self-explanatory objects, appropriate comments and other important traits, the debugging process would be very easy or otherwise, could turn into a nightmare.

Decreased times for Testing & review:

You would already know that testing and code review in it are very important phases in the development of software. If the code is very human-readable, it would be very easy for testers and code review teams to understand what the code does and carry out their processes efficiently at less time.

Justification of your work:

There would be a lot of times where you need to justify your work and explain why you have written a particular code in a particular way. With readable code, things would be more clearly understandable and explainable which makes the process of justification easy!

There are other numerous benefits for having a clean code like easing the maintenance and so on.

Conclusion:

As you have seen, writing clean code would not only help other people in the long run but also yourself! There are a lot of recommendations as to how to write clean code. A git repo adapted the book of Clean Code by Robert C.Martin for .NET and serves as a nice reference for .NET development!