Skip to content

Commit d6ec282

Browse files
committed
2 parents 1e182d5 + 7934e05 commit d6ec282

File tree

1 file changed

+19
-5
lines changed
  • Assets/GameProgramming/ServiceLocator

1 file changed

+19
-5
lines changed
Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11

22
# Service Locator
33

4+
Intent: Provide a global point of access to a service without coupling users to the concrete class that implements it.
5+
6+
When to use it:
7+
- Reduce coupling between implementation and client objects.
8+
- Similar aspects as Singleton, used to provide global access.
9+
10+
Problems:
11+
- The services have to be located. Not modular. Classes will rely in the Locator to work properly.
12+
- Is global. Any other class can poke it.
13+
- Makes testing harder.
14+
15+
Notes:
16+
- Not use it extensively. Static and Singleton problems.
17+
- Give the preference to pass services in instead using it (using constructor)
18+
- What happens if the service can’t be located/is missing? Use it alongside NullObject Pattern?
19+
- Services don't know who is locating them. It might be considered in some implementations.
20+
421
References:
5-
1. Youtube [Derek Banas](https://www.youtube.com/watch?v=AFbZhRL0Uz8&list=PLF206E906175C7E07&index=10&t=0s)
6-
2. Book [Game Programming Patterns](https://gameprogrammingpatterns.com/prototype.html)
7-
3. Github [Qian Mo](https://github.com/QianMo/Unity-Design-Pattern/tree/master/Assets/Creational%20Patterns/Prototype%20Pattern)
8-
4. Article, [Source Making](https://sourcemaking.com/design_patterns/prototype)
9-
5. Article, code examples [Guru](https://refactoring.guru/design-patterns/prototype)
22+
1. Book [Game Programming Patterns](https://gameprogrammingpatterns.com/service-locator.html)
23+
2. Github [Qian Mo](https://github.com/QianMo/Unity-Design-Pattern/tree/master/Assets/Game%20Programming%20Patterns/Service%20Locator%20Pattern)

0 commit comments

Comments
 (0)