March 2018
Intermediate to advanced
208 pages
4h 52m
English
| | class Rover { |
| » | static final double WalkingSpeed = 3; |
| | |
| » | final String SerialNumber; |
| » | double MilesPerHour; |
| | |
| » | Rover(String NewSerialNumber) { |
| | SerialNumber = NewSerialNumber; |
| | } |
| | |
| » | void Drive() { |
| | MilesPerHour = WalkingSpeed; |
| | } |
| » | void Stop() { |
| | MilesPerHour = 0; |
| | } |
| | } |
We have to name a lot of stuff in Java: packages, classes, interfaces, enums, methods, variables, fields, parameters, and constants. Take a look at the code above—it contains a lot of names. Do you notice anything strange? Can you see the pattern?
We consistently named everything in CamelCase: no spaces, and all words start with a capital letter. As long as we’re consistent, we can choose any way of naming, can’t we?
Well, in theory ...