Context Object Pattern (God Object)#
Although some say it’s an anti-pattern if used improperly, I think if used properly, it can be a very powerful pattern as it empowers data sharing and encapsulation. The tagline God Object To Rule Them All is indeed true and can be difficult to maintain - but if you compose them well, then each sub-component can be decoupled and each sub-component can be tested and maintained independently.
Especially in machine learning and deep learning, it’s very common to have a lot of parameters and configurations that are needed for the system to run, and it’s very easy to end up with a billion of hyperparameters and configurations. People would then try to group all these parameters into a single object, which is the god object.
See the series of articles on config management and you will see how I composed the configurations into a single object.
- Link to state and config and metadata management. 
- Closely related to: - Dependency Injection 
- Service Locator 
- Context Object 
- Parameter Object 
 
- Some will say god object if it stores too many things 
- So you can compose them! 
- Link to dataclass and data class code smell. 
 
    
  
  
