Latest revision |
Your text |
Line 1: |
Line 1: |
− | The aim method results in an infinite loop/stack overflow, note that ball is an exception of type Ball. This results in a logical flow of aim, "throw," "catch," repeat, though this is only logical by word choice, and is nonsensical from a programming perspective. {{unsigned|108.48.215.61}} | + | The aim method results in an infinite loop/stack overflow, note that ball is an exception of type Ball. This results in a logical flow of aim, "throw," "catch," repeat, though this is only logical by word choice, and is nonsensical from a programming perspective. |
− | :Just as the game of catch is nonsensical from a logistics perspective! [[User:Mumiemonstret|Mumiemonstret]] ([[User talk:Mumiemonstret|talk]]) 14:20, 20 March 2015 (UTC)
| + | |
| Pretty sure the code is also intentionally hard to follow. {{unsigned|108.48.215.61}} | | Pretty sure the code is also intentionally hard to follow. {{unsigned|108.48.215.61}} |
| | | |
Line 112: |
Line 112: |
| | | |
| I loved ingenious solution in original code to the "ball to the balls" side effect that is so often seen when teaching catch - [[Special:Contributions/166.147.120.176|166.147.120.176]] 12:07, 21 March 2013 (UTC) | | I loved ingenious solution in original code to the "ball to the balls" side effect that is so often seen when teaching catch - [[Special:Contributions/166.147.120.176|166.147.120.176]] 12:07, 21 March 2013 (UTC) |
− | :Just to clarify, programmer can't assume that child will inherit "catch" function as intended. That is something they really have to learn for themselves. I wonder if this is how terminator got started? - [[Special:Contributions/166.147.120.148|166.147.120.148]] 17:32, 21 March 2013 (UTC)
| |
− |
| |
− | The code quality remark #4 doesn't seem correct. In Java the constructor will ''always'' call the superclass constructor first. If not stated explicitly, it will happen implicitly. So the default empty constructor of Object ''will'' actually be called. Is this a misunderstanding, or is the guideline meant to be that the superclass constructor call should always be coded explicitly ? (which is a highly debatable guideline) --[[Special:Contributions/141.101.105.234|141.101.105.234]] 16:19, 8 January 2015 (UTC)
| |
− | : There's a lot debatable in those guidelines.
| |
− | :# Good API code needs good javadoc documentation, but this isn't exporting an API, it's a simple self-contained tool, and the code is written to be "readable" which tends to work better than even code documentation (which is always wrong, given enough time).
| |
− | :# Once again, this code describes a self-contained tool, and is nowhere near complex enough to require splitting into packages.
| |
− | :# While it contains good advice (don't expose inner logic and data), it also contains bad advice (getters and setters to access the data - you're back to exposing inner logic and data), and BETTER advice is to prefer immutable data where possible. All of this is moot, because this example doesn't expose anything - the data is package-private, and the main method can access even private members since it's in the same class as the member, and the data member can't be immutable because the parent object needs to be updated after construction to point to the child object.
| |
− | :# As mentioned above, this isn't even advice. In Java you MUST call a super class constructor as the first line in any constructor; omitting any such call implies a call to the super class constructor with no arguments, and is an error if no such constructor exists. Suggesting that you SHOULD call a super class constructor is just misleading - other than being required by the language, why else should you call a super constructor first (as opposed to later?)?
| |
− | :# Don't borrow trouble from the future. A method internal to a class has every right to refer to a member of the same class without qualification, and is usually more readable for it. Using getter methods from within the class simply to wrap access to internal fields is a terrible idea for a couple of reasons, although wrapping access with null-checks or common coersions can simplify the logical flow of your code... but even that is probably better done with utility methods (taking the field as an argument) than member methods (returning some variation on the field).
| |
− | : New Java developers who happen to come here and see the notes on quality, just note that they aren't notes that point you to GOOD quality.
| |
− | :[[Special:Contributions/108.162.250.161|108.162.250.161]] 02:15, 17 July 2015 (UTC)
| |
− | ::I've removed the style guidelines, since they don't really make the explanation better. [[User:APerson|APerson]] ([[User talk:APerson|talk!]]) 00:11, 21 October 2017 (UTC)
| |
− | The first time I used Eclipse, I couldn't find the run button for my Java applet XD [[User:625571b7-aa66-4f98-ac5c-92464cfb4ed8|625571b7-aa66-4f98-ac5c-92464cfb4ed8]] ([[User talk:625571b7-aa66-4f98-ac5c-92464cfb4ed8|talk]]) 05:54, 8 March 2017 (UTC)
| |