Abstract
Good design
We should make all attributes within the class private.
Use methods to enforce access or modify attribute values if necessary, but this is generally not recommended.
private
- When a field or OOP Method is declared as
private, it can only be accessed within the class in which it is declared. Direct access from outside the class is not allowed. This helps with maintaining the abstraction barrier
Important
Objects of the same class can access each other’s
privatefields and methods. Because theprivateaccess modifier restricts access at the class level, not the object level.
