Gheorghe Curelet-Balan Blog

Tuesday, April 08, 2014

Object-oriented design decisions should consider code testability.

How easy can we test the code and how easy can we troubleshoot it if something goes wrong. The answers to these questions depend on how the code was designed.

A good test should be able to easily test any portion of the application.

Misko Hevery has great tips on how to design code for this purpose in his 2008 talk Don't Look for Things!:

- Class constructors should be simple, reduced eventually to only assignments.
- The use of Service Locator should be avoided (see minute 8:45).
- Dependency Injection (DI) is the solution to Law of Demeter (minute 19:14)
- Rules for object factories use (minute 22:00)
- Why NULL testing paranoia is bad for testing (minute 23:57)
- use of Google's Guice framework to build auto dependencies via reflection (minute 32:40)

Labels: , , ,

0 Comments:

Post a Comment

<< Home