{"action":"created","issue":{"url":"https://api.github.com/repos/magento/marketplace-eqp/issues/27","repository_url":"https://api.github.com/repos/magento/marketplace-eqp","labels_url":"https://api.github.com/repos/magento/marketplace-eqp/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/magento/marketplace-eqp/issues/27/comments","events_url":"https://api.github.com/repos/magento/marketplace-eqp/issues/27/events","html_url":"https://github.com/magento/marketplace-eqp/issues/27","id":191991449,"number":27,"title":"Use of protected class members is discouraged","user":{"login":"ivanweiler","id":568785,"avatar_url":"https://avatars.githubusercontent.com/u/568785?v=3","gravatar_id":"","url":"https://api.github.com/users/ivanweiler","html_url":"https://github.com/ivanweiler","followers_url":"https://api.github.com/users/ivanweiler/followers","following_url":"https://api.github.com/users/ivanweiler/following{/other_user}","gists_url":"https://api.github.com/users/ivanweiler/gists{/gist_id}","starred_url":"https://api.github.com/users/ivanweiler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivanweiler/subscriptions","organizations_url":"https://api.github.com/users/ivanweiler/orgs","repos_url":"https://api.github.com/users/ivanweiler/repos","events_url":"https://api.github.com/users/ivanweiler/events{/privacy}","received_events_url":"https://api.github.com/users/ivanweiler/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-28T12:16:00Z","updated_at":"2016-11-28T15:00:55Z","closed_at":null,"body":"Hello Magento,\r\n\r\nJust a question, can you please explain why using protected is considered bad practice in Magento:\r\n\"WARNING | Use of protected class members is discouraged.\"\r\n\r\nWe're trying to prepare one extension for marketplace, and we deliberately used protected on few places to give other developers a chance to extend and change behavior of some classes if ever needed. If we change everything to private, any kind of class extensibility is harder to achieve.\r\n\r\nI'm just not sure if discouraging protected is a good idea, they have their own purpose, so we would like to know logic behind this so we could follow best practices better :)\r\n\r\nThanks, Ivan\r\n  "},"comment":{"url":"https://api.github.com/repos/magento/marketplace-eqp/issues/comments/263292896","html_url":"https://github.com/magento/marketplace-eqp/issues/27#issuecomment-263292896","issue_url":"https://api.github.com/repos/magento/marketplace-eqp/issues/27","id":263292896,"user":{"login":"danslo","id":743661,"avatar_url":"https://avatars.githubusercontent.com/u/743661?v=3","gravatar_id":"","url":"https://api.github.com/users/danslo","html_url":"https://github.com/danslo","followers_url":"https://api.github.com/users/danslo/followers","following_url":"https://api.github.com/users/danslo/following{/other_user}","gists_url":"https://api.github.com/users/danslo/gists{/gist_id}","starred_url":"https://api.github.com/users/danslo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danslo/subscriptions","organizations_url":"https://api.github.com/users/danslo/orgs","repos_url":"https://api.github.com/users/danslo/repos","events_url":"https://api.github.com/users/danslo/events{/privacy}","received_events_url":"https://api.github.com/users/danslo/received_events","type":"User","site_admin":false},"created_at":"2016-11-28T15:00:55Z","updated_at":"2016-11-28T15:00:55Z","body":"As far as I understood, it's due to the principles of [Composition over inheritance](https://en.wikipedia.org/wiki/Composition_over_inheritance). \r\n\r\nSo instead of using protected methods, split this functionality into a different class and inject it. Then it will be easier to override this functionality via plugins, because this separate class contains less logic but still needs to expose at least 1 public method.\r\n\r\nAnother thing worth mentioning is that these are specifically marked as warnings rather than errors. It's almost impossible to create extensions that don't make use of protected properties/methods because of the state of the Magento core itself."}}
{"actor":{"display_login":"danslo"}}