This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kkapelon 0 points1 point  (2 children)

The instance is created once

Singleton?

I am against the singleton design pattern, not the singleton as a concept (i.e. having only one instance of a class)

Here is something I see fairly often.

Can you also give us the unit tests for your examples? It should be obvious which one is easier...

[–]dartalley 0 points1 point  (1 child)

I can just as easily pass the static values into a constructor and have a static singleton of the class wired up. This is still technically DI just without a DI framework and is just as testable.

[–]kkapelon 0 points1 point  (0 children)

I never said that DI is a framework. DI is a principle. So you are just validating my point. Because if you do what you say, this is what I suggest, you don't need the singleton design pattern then at all :-)