Entries from August 2008

My main() Method Is Better Than Yours

August 29th, 2008 · 7 Comments

By Miško Hevery People are good at turning concrete examples into generalization. The other way around, it does not work so well. So when I write about general concepts it is hard for people to know how to translate the general concept into concrete code. To remedy this I will try to show few examples [...]

Tags: Advice · Rant · Testability

Root Cause of Singletons

August 25th, 2008 · 38 Comments

Since I have gotten lots of love/hate mail on the Singletons are Pathological Liars and Where Have All the Singletons Gone I feel obliged to to do some root cause analysis. Lets get the definition right. There is Singleton the design pattern (Notice the capital “S” as in name of something) and there is a [...]

Tags: Advice · Rant · Testability

Where Have All the Singletons Gone?

August 21st, 2008 · 24 Comments

by Miško Hevery In Singletons are Pathological Liars we discussed the problems of having singletons in your code. Let’s build on that and answer the question “If I don’t have singletons how do I ensure there is only one instance of X and how do I get X to all of the places it is [...]

Tags: Advice · OO · Rant · Testability

Changing Developer Behavior – Part 1

August 19th, 2008 · 2 Comments

by Miško Hevery | 19 August 2008 | republished from alphaITjournal So you’ve figured out a better way of doing things, but how do you get everyone to change the way they work and start writing code in this better way? This is something I face daily in my line of work as a best [...]

Tags: Advice · Rant · Testability Explorer

How I got Started Programming

August 18th, 2008 · No Comments

Tagged by Dave Astels How old were you when you started programming? It is hard to believe but I was 8 years old. 1984 was the year and we just got Sinclair ZX Spectrum + (also here). How did you get started programming? Well ZX Spectrum has BASIC and so it went on from there. [...]

Tags: Uncategorized

Singletons are Pathological Liars

August 17th, 2008 · 77 Comments

by Miško Hevery So you join a new project, which has an extensive mature code base. Your new lead asks you to implement a new feature, and, as a good developer, you start by writing a test. But since you are new to the project, you do a lot of exploratory “What happens if I [...]

Tags: Advice · OO · Rant · Testability

Procedural Language Eliminated GOTOs; OO Eliminated IFs

August 14th, 2008 · 7 Comments

by Miško Hevery Procedural languages allowed us to remove GOTOs in our code. I would like to think that OO languages allow us to remove IFs (conditionals). I know you can’t remove of all the IFs, but it is interesting just how many IFs you can remove in an application. You can’t remove these IFs: [...]

Tags: Advice · OO · Testability · Uncategorized

Circular Dependency in constructors and Dependency Injection

August 1st, 2008 · 27 Comments

by Miško Hevery So you discovered dependency injection and GUICE and you are happily refactoring and writing new tests for you code until you come across this circular reference. class A { final B b; A(B b){ this.b = b; } } class B { final A a; B(){ this.a = new A(this); } } [...]

Tags: Advice · OO · Testability