Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin class might inherit core class #28

Open
mkind opened this issue Oct 4, 2016 · 2 comments
Open

Plugin class might inherit core class #28

mkind opened this issue Oct 4, 2016 · 2 comments

Comments

@mkind
Copy link
Member

mkind commented Oct 4, 2016

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
Copy link
Collaborator

bontric commented Oct 4, 2016

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
Copy link
Member Author

mkind commented Oct 6, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants