Manuel Meyer
1 min readSep 15, 2022

--

I'd go so far to say, that if it contains singletons, it cant be regarded as OO.

If you check my profile, you will notice, that I write about declarative coding. in declarative code you also cant have singletons, as this would destroy, what I call "alignment" between coder and compiler: the singleton would not contribute to the (sub-)systems signature — which means the coder would be lying to the compiler — which is a guarantee for issues later down the road — for us. I'd also make the case that Singletons do violate every of the SOLID principles:

* SRP: no matter what they are meant to be doing, they also manage their life and therefor memory — so at least 2 things that they are doing

* OCP: yeah, they mess with that a lot. I am not even sure what the should do here

* LSP: same as OCP — what would we expect here?

* ISP: if you invoke this interface segregation principle, you singleton must be quite messy already

* DIP: singletons are made to violate this by design by not requiring proper dependency management, which circles back to SRP, too

--

--

Manuel Meyer
Manuel Meyer

Written by Manuel Meyer

Freelance Software Developer and Code Strategist.

Responses (1)