OOP — Object Oriented Programming

By Karol Bocian | March 17, 2020

A good way to start object-oriented programming by analyzing the problem and designing a solution. A very helpful step (especially in maintaining high-quality software) is field modeling.

Notions:

Object-oriented programming — a technique of creating computer programs using classes and objects that communicate with each other and invoke their methods.

Objects — software elements combining state (data) and behavior (methods).

Analysis — examination of a problem.

Object analysis — examination and classification of conceptual objects in a problem.

Design — creating a conceptual solution.

Object design — creating a conceptual solution based on objects, their responsibilities, communication between them, relations and dependencies.

Design patterns — common solutions to typical problems.

Domains model — reflecting parts of the real world and their dependencies.

Coupling — a measure of how many objects depend on each other.

Consistency — a measure of how much the methods of a given class are functionally related to each other.

Object-oriented domain modeling includes:

  • Conceptual classes — an object occurring in the modeled domain. They may correspond to nouns from the world description. When modeling, one should think about the real world, not software artifacts (e.g., a database).
  • Links — these are relationships between classes. They may correspond to verbs from the description of the world. Relationships between classes are determined by sentences, e.g. John (class Person) lives at an address (class Address).
  • Size — the attribute of the link. It specifies the number of copies of a class A linked to one copy of class B.
  • Attributes — describes copies of conceptual classes. Problems:
    • The attribute (class field) can be a different class (e.g. in Person we can give the fields Street, House No. and we can give the class Address, which will contain these fields) or the attribute of another class (e.g. number is the attribute of Place and not Ticket).
    • Attributes are values of basic types (otherwise they are conceptual classes).

The order of object-oriented domain modeling:

  • The classification of objects.
  • Consideration of relationships between classes.
  • Classification of class attributes.

It is worth taking care of high-class consistency and should not be afraid to create auxiliary classes.

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

Sources

Main image

Materials