{"action":"created","issue":{"url":"https://api.github.com/repos/tommohawkaction/YoutubeTileGame/issues/1","labels_url":"https://api.github.com/repos/tommohawkaction/YoutubeTileGame/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/tommohawkaction/YoutubeTileGame/issues/1/comments","events_url":"https://api.github.com/repos/tommohawkaction/YoutubeTileGame/issues/1/events","html_url":"https://github.com/tommohawkaction/YoutubeTileGame/issues/1","id":57857214,"number":1,"title":"A few suggestions.","user":{"login":"JustGregory","id":3115475,"avatar_url":"https://avatars.githubusercontent.com/u/3115475?v=3","gravatar_id":"","url":"https://api.github.com/users/JustGregory","html_url":"https://github.com/JustGregory","followers_url":"https://api.github.com/users/JustGregory/followers","following_url":"https://api.github.com/users/JustGregory/following{/other_user}","gists_url":"https://api.github.com/users/JustGregory/gists{/gist_id}","starred_url":"https://api.github.com/users/JustGregory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JustGregory/subscriptions","organizations_url":"https://api.github.com/users/JustGregory/orgs","repos_url":"https://api.github.com/users/JustGregory/repos","events_url":"https://api.github.com/users/JustGregory/events{/privacy}","received_events_url":"https://api.github.com/users/JustGregory/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-16T22:11:52Z","updated_at":"2015-11-25T08:27:49Z","closed_at":null,"body":"Hello. I've been watching your tutorial series, as I've been watching a lot of Java programming video series lately. I've been developing in Java for quite some time now, so I do have some experience to share. This isn't so much an 'issue' so much as some (hopefully) acceptable hints for your coding.\r\n\r\nI've noticed that in classes with two constructors to instantiate the same things, a lot of duplication of code is taking place. This example:\r\n```\r\npublic Entity(float x,float y,float width,float height){ \r\n    this.x = x; \r\n    this.y = y; \r\n    this.width = width; \r\n    this.height = height; \r\n    boundArea = new Rectangle((int)x,(int)y,(int)width,(int)height); \r\n    velocity = new Vector2f(x, y); \r\n} \r\npublic Entity(float x,float y,float width,float height,Vector2f velocity){ \r\n    this.x = x; \r\n    this.y = y; \r\n    this.width = width; \r\n    this.height = height; \r\n    boundArea = new Rectangle((int)x,(int)y,(int)width,(int)height); \r\n    this.velocity = velocity; \r\n} \r\n```\r\nthe first constructor can be streamlined to merely throw the parameters to the other constructor, with an invocation to a new Vector2f object:\r\n```\r\npublic Entity(float x,float y,float width,float height){ \r\n    this(x, y, width, height, new Vector2f(x, y));\r\n} \r\n```\r\nIn other places, you have a field initialized to `null`, then set it to a value in the constructor. For example, in the `Player` class, for the `Texture` instance:\r\n```\r\nprivate Texture texture = null;\r\n\t\r\npublic Player(Texture texture,float x, float y, float width, float height, Vector2f velocity) {\r\n    super(x, y, width, height,velocity);\r\n    this.texture = texture;\r\n}\r\n```\r\nbut texture is not modified anywhere after instantiation. Why not simply drop the \" = null\" part of the field declaration, and make the field `final`? A few of your classes could use similar cleanup, wherever the fields are instantiated in a constructor, but not changed in the class itself."},"comment":{"url":"https://api.github.com/repos/tommohawkaction/YoutubeTileGame/issues/comments/159532968","html_url":"https://github.com/tommohawkaction/YoutubeTileGame/issues/1#issuecomment-159532968","issue_url":"https://api.github.com/repos/tommohawkaction/YoutubeTileGame/issues/1","id":159532968,"user":{"login":"jarlah","id":404102,"avatar_url":"https://avatars.githubusercontent.com/u/404102?v=3","gravatar_id":"","url":"https://api.github.com/users/jarlah","html_url":"https://github.com/jarlah","followers_url":"https://api.github.com/users/jarlah/followers","following_url":"https://api.github.com/users/jarlah/following{/other_user}","gists_url":"https://api.github.com/users/jarlah/gists{/gist_id}","starred_url":"https://api.github.com/users/jarlah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarlah/subscriptions","organizations_url":"https://api.github.com/users/jarlah/orgs","repos_url":"https://api.github.com/users/jarlah/repos","events_url":"https://api.github.com/users/jarlah/events{/privacy}","received_events_url":"https://api.github.com/users/jarlah/received_events","type":"User","site_admin":false},"created_at":"2015-11-25T08:27:49Z","updated_at":"2015-11-25T08:27:49Z","body":"there are in general a couple of more suggestions that I as a professional enterprise developer can give you. One of them is to avoid static finals, and instead go for a lazy singleton holder/creator pattern. Mainly because I see that Game for example is a singleton object, EntityHandler is a singleton object and some other classes also have the same signature. An object with mutable state. Another suggestion is to use lombok, because I see two things, either you are missing a get or you are missing some variable in the constructor. Lombok will give you time to think about the code and forget about the boiler plate stuff. No more getters and setters! (well implicitely of couse)."}}