B
B
blnk2015-11-16 19:14:42
PHP
blnk, 2015-11-16 19:14:42

Is it correct to inherit a class from a singleton?

Is inheritance from a class with a singleton a correct and competent solution? If not, why not?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-11-16
@blnk

If not, why not?

Because in the vast majority of cases singleton is not needed in principle. Avoid using this design pattern whenever possible.
I suspect that in this way you want to provide global access to things like access to the database and so on - there are other more correct solutions for this.
And inheriting from the singleton class is not correct, at least from the point of view of LSP (Liskov Substitution Principle)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question