Skip to content
0:00 / 0:00

#singletonpattern#dependencyinjection#globalstate

The Clean Code Talks - "Global State and Singletons"

Google TechTalks

349K subscribers • 62 videos on Hallway

YouTube
  • Recommended by 2 people: 2 in engineering communities.
  • A classic. People kept recommending it from 2014 to 2021.
  • Presented by Miško Hevery
  • An opinion. It argues one side of a question engineers disagree on.

Intermediate. Assumes working knowledge.

194K views17 years ago2 recommendations

Software designTools and practiceDesign patternsTestingSoftware architecture

Miško Hevery explains why global state and the singleton pattern make code difficult to test and how dependency injection solves this.

Google Tech Talks November 13, 2008 ABSTRACT The Clean Code Talk Series Speaker: Misko Hevery

Why it's here

2 people recommend this

What people say. Recommended as a classic explanation of why the singleton pattern is problematic for testability and how to avoid it.

u/iknidein r/compsci • Recommends

On “Learn NOT to use the Singleton pattern”

…testing. If you want to test a class that is using a singleton, even for an external resource like you said (maybe a database), you can't easily mock that out. Dependency injection over global state is usually the way to go. You can still have a "singleton" object without it having to be global state. I recommend watching Google's tech talk here: link to this video…

u/VORGundamin r/dotnet • Recommends

On “Dependency injection”

Check out Google Tech Talks by Miško Hevery on Youtube. link to this video link to this video