Say that we write code for a machine that it so powerful that rumors say it could generate a black hole. We need to be serious about security: we cannot let those evil international terrorists find out our black-hole-making secrets and blow half the Milky Way Galaxy.
If they managed to access our source code, they [...]
Posts Tagged ‘software quality’
How to write untestable code
January 14th, 2010
1 Comment
Don’t look for things. Ask for them!
November 26th, 2009
No Comments
Before our previous article, our code to model a mechanic used to look like this:
class Mechanic {
private final Engine engine = ServiceLocator.getCar().getEngine();
public void fixEngine() { /* … */ }
}
Luckily, we applied some dependency injection, resulting in nicer code: testable, and with an explicit dependency on the ServiceLocator:
class [...]
Can’t test that Singleton? Try Dependency Injection!
November 11th, 2009
No Comments
So you want to test this method:
public class Client {
public int process(Params params) {
final Server server = Server.getInstance();
final Data data = server.retrieveDate(params);
// do stuff
[...]


