Geeks With Blogs
Swiss Coder .net and stuff... July 2013 Entries
Clean code talks by Misko Hevery - Part 4: Global State and Singletons

Global state (and singletons) is a big problem for testing because the global state cannot be controlled by the tests.

Dependency injection enforces the order of initialization at compile time. No magic behind the scene, that singletons get initialized and method talk to each other without the programmer knowing it.

Posted On Wednesday, July 17, 2013 9:36 PM

Clean code talks by Misko Hevery - Part 3: Dont look for things!
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 ......

Posted On Sunday, July 7, 2013 9:50 PM

Clean code talks by Misko Hevery - Part 2: Unit Testing
He says something brilliant: There is no secret to writing tests...... there are only secrets to writing testable code!Unit Tests require a separation of instantiation of the object graph from the business not use new(...) in the business logic. Use not use global variables/stateno static methods ......

Posted On Wednesday, July 3, 2013 9:48 PM

Copyright © huwyss | Powered by: