splone / splonebox-client

A client for the splonebox
http://splonebox.io
GNU Lesser General Public License v3.0
6 stars 2 forks source link

Plugin class might inherit core class #28

Open mkind opened 8 years ago

mkind commented 8 years ago

Is it a good idea to let the class Plugin inherit from Core? 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):

bontric commented 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.

mkind commented 8 years ago

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 :)