Skip to content

Classes

Class Organization

Public functions should follow the list of variables. We like to put the private utilities called by a public function right after the public function itself.

Encapsulation:

Loosening encapsulation is always a last resort.

Classes Should Be Small!

Single Responsibility Principle:

a class or module should have one, and only one, reason to change.

Cohesion:

A class in which each variable is used by each method is maximally cohesive. So maintain more cohesion.

Organizing for Change :

we should follow Open-Closed Principle(OCP) principle .Classes should be open for extension but closed for modification.

Isolating from Change:

Dependency Inversion Principle (DIP). the DIP says that our classes should depend upon abstractions, not on concrete details.