Kniffen Web Design

Expose Your Members

As I have begun unit testing my code my and more I've found one technique to be extremely valuable: exposing most if not all methods. This way I can test individual methods without the need devise elaborate unit testing schemes. I know this goes against the idea of unit testing only the public contract of a class or object but I am a firm believer in the idea that an object actually has two contracts an external one and one that it has to itself. Because of this it is important to test methods even if they aren't useful externally. If you want to differentiate semantically private methods you can always use a naming convention such as prepending the method name with an underscore.

Comments powered by Disqus