What are the design principles that promote testable code? (designing testable code vs driving design through tests)
Posted
by
bot
on Programmers
See other posts from Programmers
or by bot
Published on 2012-06-19T06:05:44Z
Indexed on
2012/06/19
15:24 UTC
Read the original article
Hit count: 175
unit-testing
|TDD
Most of the projects that I work on consider development and unit testing in isolation which makes writing unit tests at a later instance a nightmare. My objective is to keep testing in mind during the high level and low level design phases itself.
I want to know if there are any well defined design principles that promote testable code. One such principle that I have come to understand recently is Dependency Inversion through Dependency injection and Inversion of Control.
I have read that there is something known as SOLID. I want to understand if following the SOLID principles indirectly results in code that is easily testable? If not, are there any well-defined design principles that promote testable code?
I am aware that there is something known as Test Driven Development. Although, I am more interested in designing code with testing in mind during the design phase itself rather than driving design through tests. I hope this makes sense.
One more question related to this topic is whether it's alright to re-factor an existing product/project and make changes to code and design for the purpose of being able to write a unit test case for each module?
© Programmers or respective owner