I am writing a tool which runs several processes. These processes exchange information via message queue. It uses a config file for basic setting and writes to a log. So i pass a queue, a log object and the config down the structure of my program.
SomeClass(log, config, queue)
-> SomeClassLevel2(log, config, queue)
--> SomeClassLevel3(log, config, queue)
--> AnotherClass(log, config)
---> SomeClassLevel4(log, config)
So basicaly every class gets passed the same stuff and i have lines like this:
self.static_cluster_definition = StaticClusterDefinition(self.log, self.config)
self.dynamic_cluster_definition = DynamicClusterDefinition(self.log, self.config)
self.logic_cluster_definition = LogicClusterInformation(self.log, self.config)
self.host_definition = HostDefinition(self.log, self.config)
self.shutdown_vm = ShutdownVM(self.log, self.config)
self.vm_server_list = VMServerList(self.log, self.config)
self.vm_index = VMIndex(self.log, self.config)
Now i want to provide statistics, which have to be gathered from all over the place. So i have to introduce another object, which is passed down.
One day i would have to pass like 30 objects down the whole code structure.
Is there a better way to do this?
Aucun commentaire:
Enregistrer un commentaire