{"action":"opened","issue":{"url":"https://api.github.com/repos/clouder-community/clouder/issues/186","repository_url":"https://api.github.com/repos/clouder-community/clouder","labels_url":"https://api.github.com/repos/clouder-community/clouder/issues/186/labels{/name}","comments_url":"https://api.github.com/repos/clouder-community/clouder/issues/186/comments","events_url":"https://api.github.com/repos/clouder-community/clouder/issues/186/events","html_url":"https://github.com/clouder-community/clouder/issues/186","id":195649684,"number":186,"title":"[RFC] Improve Modularization","user":{"login":"lasley","id":7397578,"avatar_url":"https://avatars.githubusercontent.com/u/7397578?v=3","gravatar_id":"","url":"https://api.github.com/users/lasley","html_url":"https://github.com/lasley","followers_url":"https://api.github.com/users/lasley/followers","following_url":"https://api.github.com/users/lasley/following{/other_user}","gists_url":"https://api.github.com/users/lasley/gists{/gist_id}","starred_url":"https://api.github.com/users/lasley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lasley/subscriptions","organizations_url":"https://api.github.com/users/lasley/orgs","repos_url":"https://api.github.com/users/lasley/repos","events_url":"https://api.github.com/users/lasley/events{/privacy}","received_events_url":"https://api.github.com/users/lasley/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-14T21:24:13Z","updated_at":"2016-12-14T21:24:13Z","closed_at":null,"body":"This is going to be a big one, but it's kind of bugging me in the template creations so I'll probably handle it soon.\r\n\r\nWe need an interface, instead of overloading all the parent methods. The overloading isn't really scaling IMO when considering what the interpreter is going through in terms of logic. \r\n\r\nConsider a standard `deploy_base`:\r\n\r\n```\r\n...\r\n    def deploy_base(self):\r\n        \"\"\" It backs up the file store \"\"\"\r\n        res = super(ClouderBackup, self).deploy_base()\r\n        if self.base_id.application_id.type_id.name == 'elasticsearch':\r\n            do_stuff()\r\n        return res\r\n...\r\n```\r\n\r\nWhich is fine in itself, but the whole picture becomes an N+1 issue due to the piling of super method calls + a logic statement. \r\n\r\nI propose instead that we use the core methods as an interface, then escalate to the adapter method based on its type:\r\n\r\n```\r\n...\r\n    def deploy_base(self, *args, **kargs):\r\n        return getattr(self, '%s_deploy_base' % MODULE_TYPE)(*args, **kwargs)\r\n...\r\n    def elasticsearch_deploy_base(self, *args, **kargs):\r\n        return do_stuff()\r\n```\r\n\r\nTo accomplish this, we need some sort of type declaration that would work globally (e.g. `elasticsearch`). I'm not sure where we would get this though.\r\n\r\nFrom there, we would also define a rule that I ambitiously put in my WIP ES template:\r\n\r\n>  All public methods and properties are to be prefixed with ``elastic_`` in\r\n>   order to prevent namespace clashes with existing operations, unless\r\n>    overloading and calling + returning the super.\r\n\r\nThoughts?"}}
{"actor":{"display_login":"lasley"}}