What to do for single object is required | Static and singleton | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula gr√°tis
0

What to do for single object is required | Static and singleton

Hi All As we know, fully static class and singleton both has some pros and cons over each other. However, both violates SOLID principle. So , what should be done in case one need to have only one object at all for a class? Does singleton only option?

6th Feb 2021, 12:38 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
1 Resposta
+ 1
Singleton class is really your only option for an object and is better then static class because of obvious reasons like inhertance
6th Feb 2021, 2:50 PM
D_Stark
D_Stark - avatar