Geeks With Blogs
Swiss Coder .net and stuff...


The constructor should have the objects you need as arguments. Don't use locator (object through which you get the object you actually need). In a test like this it is a lot easier to construct! You can just construct the objects needed. You don't need to construct the locator first and then reach in the locator to get the object you actually need.

--> This is law of demeter. Don't pass around objects you don't need. You don't want to know about objects you don't need.

DO this:

public House(Door door, Window window)
{
    _door = door;
    _window = window;
}


NOT this:

public House(Locator locator)
{
    _door = locator.getDoor();
    _window = locator.getWindow();
}

Posted on Sunday, July 7, 2013 9:50 PM unit testing , tdd , Unit Test | Back to top


Comments on this post: Clean code talks by Misko Hevery - Part 3: Dont look for things!

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © huwyss | Powered by: GeeksWithBlogs.net