   Design without global variables, sharing data between classes
  This is a question about the design of a program.  I am using c# where there are no global variables.  I am building an engine class that for example has an instance of a class named Config as a member (Config will store the settings for the engine).  The engine class will have other class members like Networking.  The networking class will need access to the settings in Config.  Here is what I am talkign about.namespace MyCoolEngine {class Engine {// main engine class that combines all the components.Config c;Network n;    //functions, etc...}class Config {int rate;//etc}class Network {    void init() { "need rate"    }    //etc}}In c++ I would just create a global variable Engine * g_engine, so the Network class could do g_engine->c.rate .  I can't do this in c#.  I can make Config static, or I could stick all the other classes inside the Engine class, and make the variables I need the subclasses to access inside the Engine class static.  Any better ideas for this design?   
  Chances are, the networking module will only need the config data once (and possibly when player changed some config in-game but that is also covered by the following method).I'd just pass the Config as a parameter to the Networking in the constructor or in a config() method. Networking can then configure itself with this data. Call config() again if something changes.Edit: You could also use this and then store the Config object reference in Network. I'm not familiar with C# but the idea is to have two+ references to the same Config object.   ;  Thanks for the response.  Yea I had a similar solution on my mind too.  This pure OO programming is a little pain in the butt.   ;  You could have it so that all component types have an "Engine owner" member variable that references their "owner", that is the engine object they belong to. You could then access config(or any other component) by: network.owner.config; This is better than using a global variable, because in the case of having multiple owner objects each one with different config, each child component accesses the correct config.   ;  For "global" things, I like the "service provider pattern". It means passing an instance of IServiceProvider around to every component, which can then query the service provider for the various global services it requires. See here for an implementation example.   