{"action":"closed","issue":{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2203","labels_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2203/labels{/name}","comments_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2203/comments","events_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2203/events","html_url":"https://github.com/marionettejs/backbone.marionette/issues/2203","id":54497976,"number":2203,"title":"Simplify class getters","user":{"login":"thejameskyle","id":952783,"avatar_url":"https://avatars.githubusercontent.com/u/952783?v=3","gravatar_id":"","url":"https://api.github.com/users/thejameskyle","html_url":"https://github.com/thejameskyle","followers_url":"https://api.github.com/users/thejameskyle/followers","following_url":"https://api.github.com/users/thejameskyle/following{/other_user}","gists_url":"https://api.github.com/users/thejameskyle/gists{/gist_id}","starred_url":"https://api.github.com/users/thejameskyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thejameskyle/subscriptions","organizations_url":"https://api.github.com/users/thejameskyle/orgs","repos_url":"https://api.github.com/users/thejameskyle/repos","events_url":"https://api.github.com/users/thejameskyle/events{/privacy}","received_events_url":"https://api.github.com/users/thejameskyle/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/labels/discussion","name":"discussion","color":"cccccc"},{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/labels/major","name":"major","color":"fef2c0"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-15T20:13:05Z","updated_at":"2015-03-10T23:54:31Z","closed_at":"2015-03-10T23:54:31Z","body":"Right now in Marionette we have a pattern of the following:\r\n\r\n```js\r\nFoo.extend({\r\n  bar: Bar,\r\n  // or\r\n  getBar: function() {...},\r\n\r\n  buildBar: function() {\r\n    var bar = this.bar ? new this.bar(x, y, z) : this.getBar(x, y, z);\r\n    // ...\r\n  }\r\n});\r\n```\r\n\r\nBut this is overcomplicating what could be a simple API. It could work like this:\r\n```js\r\nFoo.extend({\r\n  bar: Bar,\r\n  // or\r\n  bar: function() { return new Bar(); },\r\n  \r\n  buildBar: function() {\r\n    var bar = new this.bar(x, y, z);\r\n    // ...\r\n  }\r\n});\r\n```\r\n\r\nThis is already a pattern people are familiar with from [Backbone.Collection](https://github.com/jashkenas/backbone/blob/master/backbone.js#L964) with `model`. \r\n\r\nThe one use case that we could also potentially support if we wanted to.\r\n\r\n```js\r\nFoo.extend({\r\n  bar: function() {\r\n    if (this.x) { // <<<< Needs a reference to `this`\r\n      return new BarX();\r\n    } else {\r\n      return new BarY();\r\n    }\r\n  }\r\n});\r\n```\r\n\r\nThat could simply be:\r\n\r\n```js\r\nbuildBar: function() {\r\n  var bar = this.bar.prototype instanceof Bar ? new this.bar() : this.bar();\r\n  // ...\r\n}\r\n```\r\n\r\nBut I'm not sure that's worth supporting."}}