'. '

Singleton

From APIDesign

(Difference between revisions)
Jump to: navigation, search
(New page: Among other things the Chapter 7 also introduces the NetBeans pattern for doing Component Injection. The claims there are not fully aligned with common know-how of developers t...)
Line 1: Line 1:
-
Among other things the [[Chapter 7]] also introduces the [[NetBeans]] pattern for doing [[Component Injection]]. The claims there are not fully aligned with common know-how of developers that use [[Dependency Injection]]. The most surprising thing is that [[NetBeans]] [[API]]s commonly contain [[singleton]]s. It is quite common to see static methods like:
+
Among other things the [[Chapter 7]] also introduces the [[NetBeans]] pattern for doing [[Component Injection]]. The claims there are not fully aligned with common know-how of developers that use [[Dependency Injection]]. The most surprising thing is that [[NetBeans]] [[API]]s commonly contain [[singleton]]s (and yet it works and supports [[testability]]). It is quite common to see static methods like:
<source lang="java">
<source lang="java">
public abstract class WindowSystem {
public abstract class WindowSystem {

Revision as of 12:47, 23 January 2010

Among other things the Chapter 7 also introduces the NetBeans pattern for doing Component Injection. The claims there are not fully aligned with common know-how of developers that use Dependency Injection. The most surprising thing is that NetBeans APIs commonly contain singletons (and yet it works and supports testability). It is quite common to see static methods like:

public abstract class WindowSystem {
  public static WindowSystem getDefault() { /* some impl */ }
}

This is something a Dependency Injection fan would have never done. Recently Witold Szczerba shared a very interesting observation on our mailing list[1]:

Now I feel totally lost. Jaroslav Tulach and Miško Hevery are, for me,
one of the most prominent and experienced people in the software
engineering, however they proclaim totally contradictory theories
about the bases for building applications. Or they not? I am still
trying to figure it out. In Chapter 7: "Use modular architecture",
Jaroslav describes the concept of generic registry, which is #2 on a
list of  "Top 10 things which make your code hard to test"[2]... Do
we have two mutually exclusive yet both correct theories?

This page is my attempt to explain this paradox. It may not be complete yet, I am still on the hunt for the little differences in initial assumptions that produce such contrary suggestions. But one day we'll get them...

Personal tools
buy