Creating Better Software Design using Unit Testing

Guidelines how applying unit testing or even TDD can improve software quality

I personally have written a lot of software with unit test, but also without unit tests. I takes a lot of practice to be able to write good unit tests. Unit tests provides the best indicator for well written software, they are a safety net for bugs which could be introduced by modifications in the code base. They give you a lot more confidence to change your code, but especially code that you are not that confident to change.

TDD or not TDD

Test driven development(TDD) is perfect if it can be applied for your project, by applying TDD you will have a lot of code coverage, because you are writing the unit tests in the first place. In TDD each new feature is implemented by first writing a unit tests for taht feature. My opinion is that TDD is not applicable in all cases, ut if the requirements are clear and well understood, TDD can really shine.

Unit testing and legacy code

Many times, as a software developer, you need to maintain legacy code. Thinking of legacy code, the first thoughts are that it is "old" code, written by other probably, or, as Kent Beck said in "Working Effective with Legacy code", legacy code is code without unit tests. Of course, you can not achieve the same unit test quality by writing unit tests for legacy code, because you are constrained to some limitations, which you can't all avoid, only by rewriting the software from scratch.

Unit tests and Software Quality

Normally, in most cases, Unit tests leads to a better software quality. Not necessary, unit testing requires also a lot of skills and clean coding practices, and by writing poor unit tests, the whole software can be negatively impacted.


DesignPatterns
unit testing software quality

21.10.2020

Acasa
pinte dan
About the Author

Dani Pinte

Dani is a software developer with over 10 years experience in developing Desktop and Web applications using Microsoft .NET Technologies. He is passionate about software, sports, travel and motorsport.



domain driven design DDD

DDD. Domain Driven Design for modelling complex business applications.


mvc mvp mvvm design patterns

MVC, MVP and MVVM Design Patterns Comparison.


clean architecture clean code

Clean Architecture: An alternative to traditional three layer database centric applications.