G
G
galithr2016-09-21 15:14:42
Design patterns
galithr, 2016-09-21 15:14:42

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

1 answer(s)
A
Alexander Ryzhov, 2016-09-29
@galithr

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 question

Ask a Question

731 491 924 answers to any question