The way of creating software using objects — elements combining data and functions. The program consists of objects communicating with each other and performing various tasks. It is a natural way of modeling reality for humans. The advantage of object-oriented programming is the ease of writing software, modifying, maintaining, developing and reusing code already written once.
Object-oriented programming features
Classes are object templates. They contain data (characteristics) and procedures (methods — actions to perform). For example, a class is a Circle, which contains the field: radius and the GiveFieldArea method (together with the implementation of the field calculation).
Objects are specific instances of classes. For example, the object is a Circle with radius equals 3 cm.
Basic principles of object-oriented programming
Hermetization consists of hiding implementation details. Objects represent a public interface that can be called by other objects. An object can only change its state. No one else can do it.
A mechanism that gives the possibility to create specialized objects based on more general objects. This allows you to share functionality. A specialized object can use part of the definition of a more general object and expand or change it.
A mechanism to treat different objects in one way inheriting the same class.
Objects are models of abstract entities that perform the tasks without showing how these activities are performed. They present a simplification of an issue.
All posts from mini project: Learn SOLID and OOP principles:
- SOLID exercises
- S like Single responsibility principle
- SOLID exercises — Kata
- O as Open-closed principle
- L jak Liskov Substitution Principle
- Interface segregation principle
- KISS — Keep it simple, stupid
- DRY — Don’t repeat yourself
- Dependency inversion principle
- SLAP — Single Level of Abstraction Principle
- Composition Over Inheritance
- Encapsulate what changes
- Lod — Law of Demeter
- ES as Exercises of Single responsibility principle
- EO as Exercises of Open/closed principle
- EL as Exercises of Liskov Substitution Principle
- EI as Eexrcises of Interface segregation principle
- ES as Exercises of Dependency Inversion Principle
- Object-oriented programming
- OOP — Object-Oriented Programming — Advice
- OOP — Object Oriented Programming
- Clean Architecture — Robert C. Martin.