OOP — Object-Oriented Programming — Advice

By Karol Bocian | March 14, 2020

Advice:

  • Learn SOLID principles and try to use it.
  • Think about class as physical object: what can it do, who can change its data, what it should not do.
  • Think, how objects can communicate with each other.
  • Base the relationships on abstraction.
  • Make hermetic objects.
  • Classes and methods should not do too much.
  • A class should change only itself data.
  • Find common responsibilities and put in special classes (like validating mail address).
  • Write clean, readable and pretty code.
  • Chose composition over inheritance.

How to better program in object-oriented paradigm:

Read a book: The Object-Oriented Thought Process — Matt Weiffeld and make exercises.

How to exercise:

Find an application, which is written in structural paradigm and change it into object-oriented.

All posts from mini project: Learn SOLID and OOP principles:

Sources

Main image

Materials