{"action":"created","comment":{"url":"https://api.github.com/repos/dockyard/reefpoints/pulls/comments/44180737","id":44180737,"diff_hunk":"@@ -0,0 +1,200 @@\n+---\n+layout: post\n+title: \"Ember Best Practices: Extend vs Mixin\"\n+social: true\n+author: Romina Vargas\n+twitter: \"i_am_romina\"\n+github: rsocci\n+published: true\n+tags: ember, javascript, best practices\n+ember_start_version: 1.13\n+---\n+\n+Code duplication: can’t live with it, _can_ live without it. As\n+developers, we’re always trying to find ways to DRY up our code. No\n+matter how big or how small an application, code duplication manages to\n+sneak its way into your files. So far in this Ember best practices series, we’ve\n+learned how to write [DRYer computed properties][mike] and [DRYer tests][lin]. What\n+about more general application code?\n+\n+In Ember, there are two main concepts that we can adapt in order to\n+share code between different parts of our application: `Ember.Mixin` and\n+`Ember.Object.extend()`. Both of these essentially achieve the same end\n+result, but depending on the scenario, one may be a better bet. Let's look at a\n+brief overview of each one.\n+\n+## Ember.Object.extend()\n+\n+Deep down, all Ember objects that we create and interact with are an extension of the\n+`Ember.Object`. `Ember.Object` itself extends [Ember.CoreObject][core], which\n+includes the [Ember.Observable][observable] mixin, and it's what gives Ember its \"properties and\n+property observing functionality.\" Without these base objects, there would be no Ember.\n+\n+We can create a new _subclass_ by calling the `extend()` method on any Ember\n+object. This will give the new subclass all of the properties of the parent class,\n+as well as any properties defined in the new one. You're also allowed to\n+overwrite any properties found in the parent by defining them in the new class.\n+If you've written an Ember App, you will be familiar with the following:\n+\n+```js\n+// routes/index.js\n+\n+export default Ember.Route.extend({\n+  // properties and things","path":"source/posts/2015-11-06-best-practices-extend-or-mixin.md","position":43,"original_position":43,"commit_id":"42e6b935fd49044a0e33bc6671175bfb8647bb64","original_commit_id":"42e6b935fd49044a0e33bc6671175bfb8647bb64","user":{"login":"michaeldupuisjr","id":1060866,"avatar_url":"https://avatars.githubusercontent.com/u/1060866?v=3","gravatar_id":"","url":"https://api.github.com/users/michaeldupuisjr","html_url":"https://github.com/michaeldupuisjr","followers_url":"https://api.github.com/users/michaeldupuisjr/followers","following_url":"https://api.github.com/users/michaeldupuisjr/following{/other_user}","gists_url":"https://api.github.com/users/michaeldupuisjr/gists{/gist_id}","starred_url":"https://api.github.com/users/michaeldupuisjr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaeldupuisjr/subscriptions","organizations_url":"https://api.github.com/users/michaeldupuisjr/orgs","repos_url":"https://api.github.com/users/michaeldupuisjr/repos","events_url":"https://api.github.com/users/michaeldupuisjr/events{/privacy}","received_events_url":"https://api.github.com/users/michaeldupuisjr/received_events","type":"User","site_admin":false},"body":"properties and **methods** perhaps?","created_at":"2015-11-06T19:59:01Z","updated_at":"2015-11-06T19:59:01Z","html_url":"https://github.com/dockyard/reefpoints/pull/426#discussion_r44180737","pull_request_url":"https://api.github.com/repos/dockyard/reefpoints/pulls/426","_links":{"self":{"href":"https://api.github.com/repos/dockyard/reefpoints/pulls/comments/44180737"},"html":{"href":"https://github.com/dockyard/reefpoints/pull/426#discussion_r44180737"},"pull_request":{"href":"https://api.github.com/repos/dockyard/reefpoints/pulls/426"}}},"pull_request":{"url":"https://api.github.com/repos/dockyard/reefpoints/pulls/426","id":49973691,"html_url":"https://github.com/dockyard/reefpoints/pull/426","diff_url":"https://github.com/dockyard/reefpoints/pull/426.diff","patch_url":"https://github.com/dockyard/reefpoints/pull/426.patch","issue_url":"https://api.github.com/repos/dockyard/reefpoints/issues/426","number":426,"state":"open","locked":false,"title":"extend vs mixin best practices blog post","user":{"login":"rsocci","id":4259637,"avatar_url":"https://avatars.githubusercontent.com/u/4259637?v=3","gravatar_id":"","url":"https://api.github.com/users/rsocci","html_url":"https://github.com/rsocci","followers_url":"https://api.github.com/users/rsocci/followers","following_url":"https://api.github.com/users/rsocci/following{/other_user}","gists_url":"https://api.github.com/users/rsocci/gists{/gist_id}","starred_url":"https://api.github.com/users/rsocci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsocci/subscriptions","organizations_url":"https://api.github.com/users/rsocci/orgs","repos_url":"https://api.github.com/users/rsocci/repos","events_url":"https://api.github.com/users/rsocci/events{/privacy}","received_events_url":"https://api.github.com/users/rsocci/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-11-06T16:25:06Z","updated_at":"2015-11-06T19:59:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"27657aa15204a6eacb8a87f4490be0c5b391d6d3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dockyard/reefpoints/pulls/426/commits","review_comments_url":"https://api.github.com/repos/dockyard/reefpoints/pulls/426/comments","review_comment_url":"https://api.github.com/repos/dockyard/reefpoints/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dockyard/reefpoints/issues/426/comments","statuses_url":"https://api.github.com/repos/dockyard/reefpoints/statuses/42e6b935fd49044a0e33bc6671175bfb8647bb64","head":{"label":"dockyard:mixin-extend-best-practices","ref":"mixin-extend-best-practices","sha":"42e6b935fd49044a0e33bc6671175bfb8647bb64","user":{"login":"dockyard","id":873981,"avatar_url":"https://avatars.githubusercontent.com/u/873981?v=3","gravatar_id":"","url":"https://api.github.com/users/dockyard","html_url":"https://github.com/dockyard","followers_url":"https://api.github.com/users/dockyard/followers","following_url":"https://api.github.com/users/dockyard/following{/other_user}","gists_url":"https://api.github.com/users/dockyard/gists{/gist_id}","starred_url":"https://api.github.com/users/dockyard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dockyard/subscriptions","organizations_url":"https://api.github.com/users/dockyard/orgs","repos_url":"https://api.github.com/users/dockyard/repos","events_url":"https://api.github.com/users/dockyard/events{/privacy}","received_events_url":"https://api.github.com/users/dockyard/received_events","type":"Organization","site_admin":false},"repo":{"id":2262874,"name":"reefpoints","full_name":"dockyard/reefpoints","owner":{"login":"dockyard","id":873981,"avatar_url":"https://avatars.githubusercontent.com/u/873981?v=3","gravatar_id":"","url":"https://api.github.com/users/dockyard","html_url":"https://github.com/dockyard","followers_url":"https://api.github.com/users/dockyard/followers","following_url":"https://api.github.com/users/dockyard/following{/other_user}","gists_url":"https://api.github.com/users/dockyard/gists{/gist_id}","starred_url":"https://api.github.com/users/dockyard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dockyard/subscriptions","organizations_url":"https://api.github.com/users/dockyard/orgs","repos_url":"https://api.github.com/users/dockyard/repos","events_url":"https://api.github.com/users/dockyard/events{/privacy}","received_events_url":"https://api.github.com/users/dockyard/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dockyard/reefpoints","description":"DockYard Blog","fork":false,"url":"https://api.github.com/repos/dockyard/reefpoints","forks_url":"https://api.github.com/repos/dockyard/reefpoints/forks","keys_url":"https://api.github.com/repos/dockyard/reefpoints/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dockyard/reefpoints/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dockyard/reefpoints/teams","hooks_url":"https://api.github.com/repos/dockyard/reefpoints/hooks","issue_events_url":"https://api.github.com/repos/dockyard/reefpoints/issues/events{/number}","events_url":"https://api.github.com/repos/dockyard/reefpoints/events","assignees_url":"https://api.github.com/repos/dockyard/reefpoints/assignees{/user}","branches_url":"https://api.github.com/repos/dockyard/reefpoints/branches{/branch}","tags_url":"https://api.github.com/repos/dockyard/reefpoints/tags","blobs_url":"https://api.github.com/repos/dockyard/reefpoints/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dockyard/reefpoints/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dockyard/reefpoints/git/refs{/sha}","trees_url":"https://api.github.com/repos/dockyard/reefpoints/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dockyard/reefpoints/statuses/{sha}","languages_url":"https://api.github.com/repos/dockyard/reefpoints/languages","stargazers_url":"https://api.github.com/repos/dockyard/reefpoints/stargazers","contributors_url":"https://api.github.com/repos/dockyard/reefpoints/contributors","subscribers_url":"https://api.github.com/repos/dockyard/reefpoints/subscribers","subscription_url":"https://api.github.com/repos/dockyard/reefpoints/subscription","commits_url":"https://api.github.com/repos/dockyard/reefpoints/commits{/sha}","git_commits_url":"https://api.github.com/repos/dockyard/reefpoints/git/commits{/sha}","comments_url":"https://api.github.com/repos/dockyard/reefpoints/comments{/number}","issue_comment_url":"https://api.github.com/repos/dockyard/reefpoints/issues/comments{/number}","contents_url":"https://api.github.com/repos/dockyard/reefpoints/contents/{+path}","compare_url":"https://api.github.com/repos/dockyard/reefpoints/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dockyard/reefpoints/merges","archive_url":"https://api.github.com/repos/dockyard/reefpoints/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dockyard/reefpoints/downloads","issues_url":"https://api.github.com/repos/dockyard/reefpoints/issues{/number}","pulls_url":"https://api.github.com/repos/dockyard/reefpoints/pulls{/number}","milestones_url":"https://api.github.com/repos/dockyard/reefpoints/milestones{/number}","notifications_url":"https://api.github.com/repos/dockyard/reefpoints/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dockyard/reefpoints/labels{/name}","releases_url":"https://api.github.com/repos/dockyard/reefpoints/releases{/id}","created_at":"2011-08-24T16:55:40Z","updated_at":"2015-11-05T09:40:39Z","pushed_at":"2015-11-06T18:40:07Z","git_url":"git://github.com/dockyard/reefpoints.git","ssh_url":"git@github.com:dockyard/reefpoints.git","clone_url":"https://github.com/dockyard/reefpoints.git","svn_url":"https://github.com/dockyard/reefpoints","homepage":"https://dockyard.com/blog","size":92205,"stargazers_count":34,"watchers_count":34,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":64,"mirror_url":null,"open_issues_count":11,"forks":64,"open_issues":11,"watchers":34,"default_branch":"master"}},"base":{"label":"dockyard:master","ref":"master","sha":"44b43c57976213d2549baf29ef7a3df14c3444e5","user":{"login":"dockyard","id":873981,"avatar_url":"https://avatars.githubusercontent.com/u/873981?v=3","gravatar_id":"","url":"https://api.github.com/users/dockyard","html_url":"https://github.com/dockyard","followers_url":"https://api.github.com/users/dockyard/followers","following_url":"https://api.github.com/users/dockyard/following{/other_user}","gists_url":"https://api.github.com/users/dockyard/gists{/gist_id}","starred_url":"https://api.github.com/users/dockyard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dockyard/subscriptions","organizations_url":"https://api.github.com/users/dockyard/orgs","repos_url":"https://api.github.com/users/dockyard/repos","events_url":"https://api.github.com/users/dockyard/events{/privacy}","received_events_url":"https://api.github.com/users/dockyard/received_events","type":"Organization","site_admin":false},"repo":{"id":2262874,"name":"reefpoints","full_name":"dockyard/reefpoints","owner":{"login":"dockyard","id":873981,"avatar_url":"https://avatars.githubusercontent.com/u/873981?v=3","gravatar_id":"","url":"https://api.github.com/users/dockyard","html_url":"https://github.com/dockyard","followers_url":"https://api.github.com/users/dockyard/followers","following_url":"https://api.github.com/users/dockyard/following{/other_user}","gists_url":"https://api.github.com/users/dockyard/gists{/gist_id}","starred_url":"https://api.github.com/users/dockyard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dockyard/subscriptions","organizations_url":"https://api.github.com/users/dockyard/orgs","repos_url":"https://api.github.com/users/dockyard/repos","events_url":"https://api.github.com/users/dockyard/events{/privacy}","received_events_url":"https://api.github.com/users/dockyard/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dockyard/reefpoints","description":"DockYard Blog","fork":false,"url":"https://api.github.com/repos/dockyard/reefpoints","forks_url":"https://api.github.com/repos/dockyard/reefpoints/forks","keys_url":"https://api.github.com/repos/dockyard/reefpoints/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dockyard/reefpoints/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dockyard/reefpoints/teams","hooks_url":"https://api.github.com/repos/dockyard/reefpoints/hooks","issue_events_url":"https://api.github.com/repos/dockyard/reefpoints/issues/events{/number}","events_url":"https://api.github.com/repos/dockyard/reefpoints/events","assignees_url":"https://api.github.com/repos/dockyard/reefpoints/assignees{/user}","branches_url":"https://api.github.com/repos/dockyard/reefpoints/branches{/branch}","tags_url":"https://api.github.com/repos/dockyard/reefpoints/tags","blobs_url":"https://api.github.com/repos/dockyard/reefpoints/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dockyard/reefpoints/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dockyard/reefpoints/git/refs{/sha}","trees_url":"https://api.github.com/repos/dockyard/reefpoints/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dockyard/reefpoints/statuses/{sha}","languages_url":"https://api.github.com/repos/dockyard/reefpoints/languages","stargazers_url":"https://api.github.com/repos/dockyard/reefpoints/stargazers","contributors_url":"https://api.github.com/repos/dockyard/reefpoints/contributors","subscribers_url":"https://api.github.com/repos/dockyard/reefpoints/subscribers","subscription_url":"https://api.github.com/repos/dockyard/reefpoints/subscription","commits_url":"https://api.github.com/repos/dockyard/reefpoints/commits{/sha}","git_commits_url":"https://api.github.com/repos/dockyard/reefpoints/git/commits{/sha}","comments_url":"https://api.github.com/repos/dockyard/reefpoints/comments{/number}","issue_comment_url":"https://api.github.com/repos/dockyard/reefpoints/issues/comments{/number}","contents_url":"https://api.github.com/repos/dockyard/reefpoints/contents/{+path}","compare_url":"https://api.github.com/repos/dockyard/reefpoints/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dockyard/reefpoints/merges","archive_url":"https://api.github.com/repos/dockyard/reefpoints/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dockyard/reefpoints/downloads","issues_url":"https://api.github.com/repos/dockyard/reefpoints/issues{/number}","pulls_url":"https://api.github.com/repos/dockyard/reefpoints/pulls{/number}","milestones_url":"https://api.github.com/repos/dockyard/reefpoints/milestones{/number}","notifications_url":"https://api.github.com/repos/dockyard/reefpoints/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dockyard/reefpoints/labels{/name}","releases_url":"https://api.github.com/repos/dockyard/reefpoints/releases{/id}","created_at":"2011-08-24T16:55:40Z","updated_at":"2015-11-05T09:40:39Z","pushed_at":"2015-11-06T18:40:07Z","git_url":"git://github.com/dockyard/reefpoints.git","ssh_url":"git@github.com:dockyard/reefpoints.git","clone_url":"https://github.com/dockyard/reefpoints.git","svn_url":"https://github.com/dockyard/reefpoints","homepage":"https://dockyard.com/blog","size":92205,"stargazers_count":34,"watchers_count":34,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":64,"mirror_url":null,"open_issues_count":11,"forks":64,"open_issues":11,"watchers":34,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dockyard/reefpoints/pulls/426"},"html":{"href":"https://github.com/dockyard/reefpoints/pull/426"},"issue":{"href":"https://api.github.com/repos/dockyard/reefpoints/issues/426"},"comments":{"href":"https://api.github.com/repos/dockyard/reefpoints/issues/426/comments"},"review_comments":{"href":"https://api.github.com/repos/dockyard/reefpoints/pulls/426/comments"},"review_comment":{"href":"https://api.github.com/repos/dockyard/reefpoints/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dockyard/reefpoints/pulls/426/commits"},"statuses":{"href":"https://api.github.com/repos/dockyard/reefpoints/statuses/42e6b935fd49044a0e33bc6671175bfb8647bb64"}}}}