Things to fix in Main.java
. Based on Google Java Style Guide
- There must be exactly one top level class
- Use 2-space block indentation
- Multiple blank lines are not encouraged (See the end of the section).
- Use vertical whitespaces between class methods (and optionally class fields)
- Use horizontal whitespaces on both sides of binary operators (e.g.
&
,>=
) - There must be a whitespace between the start of comment
//
and the comment text. The one is missing on lines 4 and 13. - There must be a whitespace after
,
on line 8 - Only one space between keyword and identifier on line 39
- Class names must be in
UpperCamelCase
- Non-constant field names must be in
lowerCamelCase
- Method names must follow
lowerCamelCase
- Use common prefixes for getters and setters:
get*
,set*
instead oftake*
orput*
- Remove IDE-generated comments (lines 4,5)
- Use common "BMI" abbreviation instead of "IMB"
- Use meaningful field names so that the comments describing their purpose could be removed
- The static method should be called in a static way (
HumanIMB.Result()
instead ofhumanIMB.Result()
) - Use
&&
instead of&
to avoid unwanted behaviour - The variable assignments could be replaced with
return
statements - The
Result
method need a better name (e.g.getBmiFeedback
) - Avoid "magic numbers". Without an IDE (e.g. while reviewing conde on GitHub, the purpose of function arguments is not clear)
- Holding
imb
in static state can lead to unwanted behaviour - Putting BMI calculation (business logic) inside a constructor is not a good practice. A dedicated method should be created
- What's the purpose of getters/setters if the fields are marked as
public
? You'd better make themprivate
- Business logic should not live in setters: it's a side effect