{"action":"created","comment":{"url":"https://api.github.com/repos/HabitRPG/habitrpg-android/pulls/comments/80180458","id":80180458,"diff_hunk":"@@ -8,34 +8,39 @@\n public class FirstDayOfTheWeekHelper {\n \n     private int firstDayOfTheWeek;\n+    private int dailyTaskFormOffset;\n \n-    public FirstDayOfTheWeekHelper(String firstDayOfTheWeekSharedPref) {\n+    private FirstDayOfTheWeekHelper(int dailyTaskFormOffset, int firstDayOfTheWeek) {\n+        this.dailyTaskFormOffset = dailyTaskFormOffset;\n+        this.firstDayOfTheWeek = firstDayOfTheWeek;\n+    }\n+\n+    public static FirstDayOfTheWeekHelper newInstance(String firstDayOfTheWeekSharedPref) {","path":"Habitica/src/main/java/com/habitrpg/android/habitica/helpers/FirstDayOfTheWeekHelper.java","position":null,"original_position":12,"commit_id":"497d574e3651c4e1e647784593c3988d19561add","original_commit_id":"e38b98a0d0472f316756ca951ee304d569672d3c","user":{"login":"DanielKaparunakis","id":13035428,"avatar_url":"https://avatars.githubusercontent.com/u/13035428?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielKaparunakis","html_url":"https://github.com/DanielKaparunakis","followers_url":"https://api.github.com/users/DanielKaparunakis/followers","following_url":"https://api.github.com/users/DanielKaparunakis/following{/other_user}","gists_url":"https://api.github.com/users/DanielKaparunakis/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielKaparunakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielKaparunakis/subscriptions","organizations_url":"https://api.github.com/users/DanielKaparunakis/orgs","repos_url":"https://api.github.com/users/DanielKaparunakis/repos","events_url":"https://api.github.com/users/DanielKaparunakis/events{/privacy}","received_events_url":"https://api.github.com/users/DanielKaparunakis/received_events","type":"User","site_admin":false},"body":"In this specific class, it decouples the logic of the class from the constructor which allows for easier testing. It is worth noting that I could have also achieved this by adding a new method and placed the logic there. This, however, would require two calls, object instantiation & method call, every time the class is used in the app. In general, static factory methods for object creation are worth considering because: One, unlike constructors, they have names, so instead of newInstance you could use very specific names describing the purpose of the constructor. Something that sometimes the method signature cannot achieve on its own. Two, unlike constructors, they are not required to create a new object each time they’re invoked, meaning you could create a static factory that returns the same instance every time whereas when you use new ClassName() you'll always return a new instance. There is a more in-depth explanation of static factory methods in Effective Java, 2nd edition.","created_at":"2016-09-23T04:30:45Z","updated_at":"2016-09-23T04:30:45Z","html_url":"https://github.com/HabitRPG/habitrpg-android/pull/620#discussion_r80180458","pull_request_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/pulls/620","_links":{"self":{"href":"https://api.github.com/repos/HabitRPG/habitrpg-android/pulls/comments/80180458"},"html":{"href":"https://github.com/HabitRPG/habitrpg-android/pull/620#discussion_r80180458"},"pull_request":{"href":"https://api.github.com/repos/HabitRPG/habitrpg-android/pulls/620"}}},"pull_request":{"url":"https://api.github.com/repos/HabitRPG/habitrpg-android/pulls/620","id":84771248,"html_url":"https://github.com/HabitRPG/habitrpg-android/pull/620","diff_url":"https://github.com/HabitRPG/habitrpg-android/pull/620.diff","patch_url":"https://github.com/HabitRPG/habitrpg-android/pull/620.patch","issue_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/issues/620","number":620,"state":"open","locked":false,"title":"Feature: First day of the week","user":{"login":"DanielKaparunakis","id":13035428,"avatar_url":"https://avatars.githubusercontent.com/u/13035428?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielKaparunakis","html_url":"https://github.com/DanielKaparunakis","followers_url":"https://api.github.com/users/DanielKaparunakis/followers","following_url":"https://api.github.com/users/DanielKaparunakis/following{/other_user}","gists_url":"https://api.github.com/users/DanielKaparunakis/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielKaparunakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielKaparunakis/subscriptions","organizations_url":"https://api.github.com/users/DanielKaparunakis/orgs","repos_url":"https://api.github.com/users/DanielKaparunakis/repos","events_url":"https://api.github.com/users/DanielKaparunakis/events{/privacy}","received_events_url":"https://api.github.com/users/DanielKaparunakis/received_events","type":"User","site_admin":false},"body":"my Habitica User-ID: a84f01a4-4c2b-4dbb-9ed0-08f106dda50c\r\n","created_at":"2016-09-10T23:28:57Z","updated_at":"2016-09-23T04:30:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"be95470ec8a1800202593681e9a859a7eec034da","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/pulls/620/commits","review_comments_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/pulls/620/comments","review_comment_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/issues/620/comments","statuses_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/statuses/497d574e3651c4e1e647784593c3988d19561add","head":{"label":"DanielKaparunakis:FirstDayOfTheWeek","ref":"FirstDayOfTheWeek","sha":"497d574e3651c4e1e647784593c3988d19561add","user":{"login":"DanielKaparunakis","id":13035428,"avatar_url":"https://avatars.githubusercontent.com/u/13035428?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielKaparunakis","html_url":"https://github.com/DanielKaparunakis","followers_url":"https://api.github.com/users/DanielKaparunakis/followers","following_url":"https://api.github.com/users/DanielKaparunakis/following{/other_user}","gists_url":"https://api.github.com/users/DanielKaparunakis/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielKaparunakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielKaparunakis/subscriptions","organizations_url":"https://api.github.com/users/DanielKaparunakis/orgs","repos_url":"https://api.github.com/users/DanielKaparunakis/repos","events_url":"https://api.github.com/users/DanielKaparunakis/events{/privacy}","received_events_url":"https://api.github.com/users/DanielKaparunakis/received_events","type":"User","site_admin":false},"repo":{"id":65703038,"name":"habitrpg-android","full_name":"DanielKaparunakis/habitrpg-android","owner":{"login":"DanielKaparunakis","id":13035428,"avatar_url":"https://avatars.githubusercontent.com/u/13035428?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielKaparunakis","html_url":"https://github.com/DanielKaparunakis","followers_url":"https://api.github.com/users/DanielKaparunakis/followers","following_url":"https://api.github.com/users/DanielKaparunakis/following{/other_user}","gists_url":"https://api.github.com/users/DanielKaparunakis/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielKaparunakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielKaparunakis/subscriptions","organizations_url":"https://api.github.com/users/DanielKaparunakis/orgs","repos_url":"https://api.github.com/users/DanielKaparunakis/repos","events_url":"https://api.github.com/users/DanielKaparunakis/events{/privacy}","received_events_url":"https://api.github.com/users/DanielKaparunakis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DanielKaparunakis/habitrpg-android","description":"Native Android","fork":true,"url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android","forks_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/forks","keys_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/teams","hooks_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/hooks","issue_events_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/issues/events{/number}","events_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/events","assignees_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/assignees{/user}","branches_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/branches{/branch}","tags_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/tags","blobs_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/statuses/{sha}","languages_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/languages","stargazers_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/stargazers","contributors_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/contributors","subscribers_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/subscribers","subscription_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/subscription","commits_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/contents/{+path}","compare_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/merges","archive_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/downloads","issues_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/issues{/number}","pulls_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/pulls{/number}","milestones_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/milestones{/number}","notifications_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/labels{/name}","releases_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/releases{/id}","deployments_url":"https://api.github.com/repos/DanielKaparunakis/habitrpg-android/deployments","created_at":"2016-08-15T03:53:31Z","updated_at":"2016-08-15T03:53:33Z","pushed_at":"2016-09-23T03:55:21Z","git_url":"git://github.com/DanielKaparunakis/habitrpg-android.git","ssh_url":"git@github.com:DanielKaparunakis/habitrpg-android.git","clone_url":"https://github.com/DanielKaparunakis/habitrpg-android.git","svn_url":"https://github.com/DanielKaparunakis/habitrpg-android","homepage":null,"size":18418,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"HabitRPG:develop","ref":"develop","sha":"6c86a83023296dd67bddded91c689b61ba2e5fcf","user":{"login":"HabitRPG","id":3834775,"avatar_url":"https://avatars.githubusercontent.com/u/3834775?v=3","gravatar_id":"","url":"https://api.github.com/users/HabitRPG","html_url":"https://github.com/HabitRPG","followers_url":"https://api.github.com/users/HabitRPG/followers","following_url":"https://api.github.com/users/HabitRPG/following{/other_user}","gists_url":"https://api.github.com/users/HabitRPG/gists{/gist_id}","starred_url":"https://api.github.com/users/HabitRPG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HabitRPG/subscriptions","organizations_url":"https://api.github.com/users/HabitRPG/orgs","repos_url":"https://api.github.com/users/HabitRPG/repos","events_url":"https://api.github.com/users/HabitRPG/events{/privacy}","received_events_url":"https://api.github.com/users/HabitRPG/received_events","type":"Organization","site_admin":false},"repo":{"id":31075682,"name":"habitrpg-android","full_name":"HabitRPG/habitrpg-android","owner":{"login":"HabitRPG","id":3834775,"avatar_url":"https://avatars.githubusercontent.com/u/3834775?v=3","gravatar_id":"","url":"https://api.github.com/users/HabitRPG","html_url":"https://github.com/HabitRPG","followers_url":"https://api.github.com/users/HabitRPG/followers","following_url":"https://api.github.com/users/HabitRPG/following{/other_user}","gists_url":"https://api.github.com/users/HabitRPG/gists{/gist_id}","starred_url":"https://api.github.com/users/HabitRPG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HabitRPG/subscriptions","organizations_url":"https://api.github.com/users/HabitRPG/orgs","repos_url":"https://api.github.com/users/HabitRPG/repos","events_url":"https://api.github.com/users/HabitRPG/events{/privacy}","received_events_url":"https://api.github.com/users/HabitRPG/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/HabitRPG/habitrpg-android","description":"Native Android","fork":false,"url":"https://api.github.com/repos/HabitRPG/habitrpg-android","forks_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/forks","keys_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/teams","hooks_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/hooks","issue_events_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/issues/events{/number}","events_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/events","assignees_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/assignees{/user}","branches_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/branches{/branch}","tags_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/tags","blobs_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/statuses/{sha}","languages_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/languages","stargazers_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/stargazers","contributors_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/contributors","subscribers_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/subscribers","subscription_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/subscription","commits_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/contents/{+path}","compare_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/merges","archive_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/downloads","issues_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/issues{/number}","pulls_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/pulls{/number}","milestones_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/milestones{/number}","notifications_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/labels{/name}","releases_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/releases{/id}","deployments_url":"https://api.github.com/repos/HabitRPG/habitrpg-android/deployments","created_at":"2015-02-20T17:21:05Z","updated_at":"2016-09-22T07:38:13Z","pushed_at":"2016-09-23T03:55:22Z","git_url":"git://github.com/HabitRPG/habitrpg-android.git","ssh_url":"git@github.com:HabitRPG/habitrpg-android.git","clone_url":"https://github.com/HabitRPG/habitrpg-android.git","svn_url":"https://github.com/HabitRPG/habitrpg-android","homepage":null,"size":18848,"stargazers_count":236,"watchers_count":236,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":110,"mirror_url":null,"open_issues_count":83,"forks":110,"open_issues":83,"watchers":236,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/HabitRPG/habitrpg-android/pulls/620"},"html":{"href":"https://github.com/HabitRPG/habitrpg-android/pull/620"},"issue":{"href":"https://api.github.com/repos/HabitRPG/habitrpg-android/issues/620"},"comments":{"href":"https://api.github.com/repos/HabitRPG/habitrpg-android/issues/620/comments"},"review_comments":{"href":"https://api.github.com/repos/HabitRPG/habitrpg-android/pulls/620/comments"},"review_comment":{"href":"https://api.github.com/repos/HabitRPG/habitrpg-android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/HabitRPG/habitrpg-android/pulls/620/commits"},"statuses":{"href":"https://api.github.com/repos/HabitRPG/habitrpg-android/statuses/497d574e3651c4e1e647784593c3988d19561add"}}}}
{"actor":{"display_login":"DanielKaparunakis"}}