Open mkind opened 8 years ago
I'm not sure what you mean by inheritance here, but it would be great if you could describe what you're thinking of. (I struggled a bit with the architecture there and I'm still not 100% convinced, so I'm open to suggestions)
The reason I did it this way is that the Core
object is only initialized once and it holds the connection. The Plugin
and every RemotePlugin
needs a reference to the core to share that single connection. So the Core
object is basically an abstraction between the RPC library and the API.
The principle behind this is called dependency injection.
Another option is to keep the Core
as a singleton, but the more I read into that the more it seemed like bad practice.
Ok, I see. Inheritance seems not the be a proper solution. I won't close this issue, since a solution might come along later on :)
Is it a good idea to let the class
Plugin
inherit fromCore
? It seems a little bit more intuitive than passing the core object like it is necessary at the moment:def __init__(self, name: str, desc: str, author: str, licence: str, core: Core):