MATTHEW VENTURES
  • Home
  • Career
    • Resume
    • About Me
  • Get Into Game Dev
    • GIGD: Fundamentals
    • GIGD: C++ Topics
    • GIGD: Data Structures
    • GIGD: Patterns
    • GIGD: Multithreading
    • GIGD: Misc Coding
    • GIGD: Maths >
      • GIGD: Maths - Vectors I
      • GIGD: Maths - Vectors II
      • GIGD: Maths - Matrices
      • GIGD: Maths - Rotations
      • GIGD: Maths - Planes
      • GIGD: Maths - Polygons & Polyhedrons
      • GIGD: Maths - AABBs & OBBs
      • GIGD: Maths - Spatial Partitions
      • GIGD: Maths - Circles & Spheres
    • GIGD: Behavioral Questions
    • GIGD: Design Questions
    • GIGD: Asking Questions
    • GIGD: Additional Reading
    • GIGD: Practice Test
  • Personal
    • Recommendations
    • Beliefs
  • Misc
    • Side Quests
    • My Companies >
      • VVLLC
      • BVP
    • Research >
      • NASA
      • Glyph: Website
      • Glyph: Awards

Service Locators & Singletons

11/5/2020

1 Comment

 
The Service Locator and Singleton patterns are both designed to decouple code and can be used in game engine's like Unity to resolve scene dependencies in exchange for a run-time acquisition of Monobehaviours we want to reference. The Singleton in particular holds a static reference to the "instance" which means any code, anywhere, can call upon it. This is a great point of access for a service but I would prefer to not requires everyone of my scripts, or "services", to need to derive from a singleton in order for me to call it in other scripts. That is where our Service Locator comes in.
The Singleton helped us to obtain any service which derived from it. However we would prefer that every script not be a singleton. Instead we can make a singleton service whose job is to find other serviced! This script is called the Service Locator. It simply caches a reference to any Monobehaviours that are requested from it.
1 Comment
Janelle Steele link
5/11/2021 09:20:33 am

Thank you for writingg this

Reply



Leave a Reply.

  • Home
  • Career
    • Resume
    • About Me
  • Get Into Game Dev
    • GIGD: Fundamentals
    • GIGD: C++ Topics
    • GIGD: Data Structures
    • GIGD: Patterns
    • GIGD: Multithreading
    • GIGD: Misc Coding
    • GIGD: Maths >
      • GIGD: Maths - Vectors I
      • GIGD: Maths - Vectors II
      • GIGD: Maths - Matrices
      • GIGD: Maths - Rotations
      • GIGD: Maths - Planes
      • GIGD: Maths - Polygons & Polyhedrons
      • GIGD: Maths - AABBs & OBBs
      • GIGD: Maths - Spatial Partitions
      • GIGD: Maths - Circles & Spheres
    • GIGD: Behavioral Questions
    • GIGD: Design Questions
    • GIGD: Asking Questions
    • GIGD: Additional Reading
    • GIGD: Practice Test
  • Personal
    • Recommendations
    • Beliefs
  • Misc
    • Side Quests
    • My Companies >
      • VVLLC
      • BVP
    • Research >
      • NASA
      • Glyph: Website
      • Glyph: Awards