Another Good Tidbit from GOOSGBT

Posted by: James Carr on March 9, 2010

I’m currently in chapter 12 of Growing Object Oriented Software Guided By Tests and thought I’d share another good tidbit from one of the asides:

Put Tests in a Different Package

We’ve adopted a habit of putting tests in a different package from the code they’re exercising. We want to make sure we’re driving the code through its public interfaces, like any other client, rather than opening up a package-scoped back door for testing.

Good point! Almost everytime I’ve found my self expose a method that should be private as protected or default it’s been because that method was really in gross violation of Single Responsibility Principle and I’ve often taken such code and extracted it to a separate object.

Thoughts?

James Carr

About James Carr

James is a contractor in the St.Louis area that shares a passion for software craftsmanship and has enjoyed software development since he wrote his first program in Basic on the Tandy Color Computer 3 way back in 1988.

In addition to a passion for technology, he also has a keen interest in improving teamwork and collaboration through interactive activities to get people thinking creatively and develop stronger, richer communication channels with their stakeholders.