Stephan van Hulst wrote:Don't use floating point values for anything other than imprecise measurements. Your account balance should be an integer and your interest rate either an integer or a BigDecimal.
IDs should be strings, not integers.
Make the ID and creation time of an account final.
Make all methods that are not intended to be overridden final. When in doubt, make it final.
Perform parameter validation in your mutators. You should not be able to withdraw or deposit negative amounts. Also, check for integer overflows.
Validate class invariants by throwing exceptions. When you try to withdraw more than the overdraft limit allows, throw an exception.
Don't use long sequences of string concatenations. Use a formatter instead.
An object of a subclass can be used wherever its superclass object is
used. This is commonly known as polymorphism (from a Greek word meaning “many
forms”). In simple terms, polymorphism means that a variable of a supertype can refer to
a subtype object.
Polymorphism means that a variable of a supertype can refer to a subtype object.