Answer the question
In order to leave comments, you need to log in
What is the difference between Registry and ServiceLocator?
Studying patterns... I read about Service Locator and Registry - but I can't understand what is the difference, in fact both patterns store an array of objects and give access to them. Actually the question is - what are the differences between these patterns?
Answer the question
In order to leave comments, you need to log in
If you think about it, both can be attributed to factories that generate objects, they also have in common - registration of instances that they can provide. The difference is that Registry is more explicit. when obtaining the necessary object, it is clearly clear what type of objects the Registry can provide. In ServiceLocator, however, it does not say with its interface what it has, you can register almost any class in it, and you will only know it at runtime. This implicitness in most cases makes this pattern an antipattern.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question