{"action":"created","issue":{"url":"https://api.github.com/repos/teamed/qulice/issues/471","labels_url":"https://api.github.com/repos/teamed/qulice/issues/471/labels{/name}","comments_url":"https://api.github.com/repos/teamed/qulice/issues/471/comments","events_url":"https://api.github.com/repos/teamed/qulice/issues/471/events","html_url":"https://github.com/teamed/qulice/issues/471","id":109437151,"number":471,"title":"We should be able to have constructor parameters with the same names as the fields","user":{"login":"Suseika","id":4467948,"avatar_url":"https://avatars.githubusercontent.com/u/4467948?v=3","gravatar_id":"","url":"https://api.github.com/users/Suseika","html_url":"https://github.com/Suseika","followers_url":"https://api.github.com/users/Suseika/followers","following_url":"https://api.github.com/users/Suseika/following{/other_user}","gists_url":"https://api.github.com/users/Suseika/gists{/gist_id}","starred_url":"https://api.github.com/users/Suseika/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Suseika/subscriptions","organizations_url":"https://api.github.com/users/Suseika/orgs","repos_url":"https://api.github.com/users/Suseika/repos","events_url":"https://api.github.com/users/Suseika/events{/privacy}","received_events_url":"https://api.github.com/users/Suseika/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/teamed/qulice/labels/30%20mins","name":"30 mins","color":"eb6421"},{"url":"https://api.github.com/repos/teamed/qulice/labels/@krzyk","name":"@krzyk","color":"009801"},{"url":"https://api.github.com/repos/teamed/qulice/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/teamed/qulice/labels/DEV","name":"DEV","color":"bfd4f3"},{"url":"https://api.github.com/repos/teamed/qulice/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":{"login":"krzyk","id":105730,"avatar_url":"https://avatars.githubusercontent.com/u/105730?v=3","gravatar_id":"","url":"https://api.github.com/users/krzyk","html_url":"https://github.com/krzyk","followers_url":"https://api.github.com/users/krzyk/followers","following_url":"https://api.github.com/users/krzyk/following{/other_user}","gists_url":"https://api.github.com/users/krzyk/gists{/gist_id}","starred_url":"https://api.github.com/users/krzyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krzyk/subscriptions","organizations_url":"https://api.github.com/users/krzyk/orgs","repos_url":"https://api.github.com/users/krzyk/repos","events_url":"https://api.github.com/users/krzyk/events{/privacy}","received_events_url":"https://api.github.com/users/krzyk/received_events","type":"User","site_admin":false},"milestone":null,"comments":10,"created_at":"2015-10-02T06:24:27Z","updated_at":"2015-10-15T06:14:06Z","closed_at":"2015-10-15T06:14:06Z","body":"We have a rule that parameters' names must be different from fields' names. Generally it is really useful and helps prevent some overlooked problems. \r\n\r\nBut there is one exception. This rule is absolutely *destructive* to code quality when applied to constructors.\r\n\r\nGenerally we have just assignments in constructors:\r\n```java\r\npublic Rectangle(final int w, final int h) {\r\n    this.width = w;\r\n    this.height = h;\r\n}\r\n```\r\n\r\nParameters in constructors must be the same things as the fields, because they are just assigned to fields and not operated upon in any way. And if thing A and thing B are the same thing used for the same reason, then A and B should have the same name. But they can't because of our rules.\r\n\r\nCurrent rule leads to us inventing synonyms, like `w` instead of `width` and `h` instead of `heght`. Sometimes those synonyms are easy to figure out, sometimes they are really hard. I don't think we should be doing this. Synonyms in code are a disaster.\r\n\r\nAnother thing is that a constructor parameter's name and field name are important for different reasons. Constructor parameter names show up in completion dialogues in IDE, and field names show up in the code of class. Both constructor parameters and fields should have expressive names, but our quality standards don't allow them both to be maximally expressive.\r\n\r\n### What we should do\r\n\r\nI think that we should be *enforcing* constructor parameters to have the same names as field names. Current approach harms code quality, and the suggested approach actually improves it. A properly designed class would never actually need a constructor parameter to have different name from the field it is stored in.\r\n\r\nIf it is too difficult to enforce the naming for constructor parameters (or if you think that it is not a good idea), then at least excluding constructor parameters from the `HiddenFieldCheck` would be a huge improvement."},"comment":{"url":"https://api.github.com/repos/teamed/qulice/issues/comments/148292215","html_url":"https://github.com/teamed/qulice/issues/471#issuecomment-148292215","issue_url":"https://api.github.com/repos/teamed/qulice/issues/471","id":148292215,"user":{"login":"Suseika","id":4467948,"avatar_url":"https://avatars.githubusercontent.com/u/4467948?v=3","gravatar_id":"","url":"https://api.github.com/users/Suseika","html_url":"https://github.com/Suseika","followers_url":"https://api.github.com/users/Suseika/followers","following_url":"https://api.github.com/users/Suseika/following{/other_user}","gists_url":"https://api.github.com/users/Suseika/gists{/gist_id}","starred_url":"https://api.github.com/users/Suseika/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Suseika/subscriptions","organizations_url":"https://api.github.com/users/Suseika/orgs","repos_url":"https://api.github.com/users/Suseika/repos","events_url":"https://api.github.com/users/Suseika/events{/privacy}","received_events_url":"https://api.github.com/users/Suseika/received_events","type":"User","site_admin":false},"created_at":"2015-10-15T06:14:06Z","updated_at":"2015-10-15T06:14:06Z","body":"@krzyk Great, thanks"}}