Blog

Writing testable code matters

Do you tell your client “I cannot write testable code; writing testable code is not in my genes. My code is crap and it can only be tested with hard manual efforts; my code sucks and I am not a professional”. Do you think customers will come to you for the services you offer?

How about exact opposite stand – “I am professional developer, my code is 100% testable with full automation in place. And I am top 5% of the developers who can write testable code”.

I think you know the answer, customers will come to you, only when they know that you are good at developing top-notch software, not the other way around.

Most of the time, because of various reasons, it is very difficult to come up with a good unit test plan that can cover every possible combination of inputs and external conditions, and still meet the software release deadlines. And hence writing testable code is one of the challenges we face during software development life cycle.

In this post I am trying to address important aspects of “testable code” that will help you to become a professional C# .NET developer. Be a pro my friend, not an a??hole, who can’t write testable code.

Why should you care for writing testable code?

Number one reason is – “to maintain quality of the software”.

Subsequent reasons are – “to maintain quality of the software”.

What on earth tells you that there could be other reasons too?

Or perhaps you want to become a lazy nerd who just want to “test the code for each code check-in, in an automated manner”. Dam, you are my type ;).

We are taking all the pain just to find bugs as early as possible. (In good old earlier days, management used to fear instantly, whenever developers try to change even single line of code. This scenario is now changing with automation in place).

When a unit test case is added in the form code, it serves as a live documentation for the code under test.