What is a “type”?
Abstract classes versus interfaces
Neither can be instantiated as object, both can specify behaviour and data
An interface is a collection of behaviour offered by an object of that type:
- Methods are defined but empty, all of them must be implemented in the class
- A class can implement multiple interfaces, since interfaces are not inheritance
An abstract class is abstracted behaviour of a collection of classes:
- Methods can be abstract (no implementation) or concrete (with implementation)
- Are (should be) part of an inheritance structure
Enumeration (enums)
Record
Designed to store fixed values
Automatically have:
- Private field for each component
- Public getter
- Public constructor
- Implemented toString() method
SOLID
KISS: Keep It Simple, Silly!
It does not help to have a complicated solution nobody understands
Simpler solutions are less error-prone