Monthly Archives: March 2020

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… Read More »

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… Read More »

Object-oriented programming

By Karol Bocian | March 13, 2020

Object-oriented programming 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… Read More »

ES as Exercises of Dependency Inversion Principle

By Karol Bocian | March 11, 2020

Dependency inversion principle High-level modules should not depend on low-level modules, but the dependence should result from abstraction. How to use DIP in practice? We should make many abstract creatures. Every class should implement interface or inherits abstract class. At the beginning of making task, we can write only interfaces. Helpfully to achieve the DIP… Read More »

EL as Exercises of Liskov Substitution Principle

By Karol Bocian | March 7, 2020

Liskov substitution principle The application should work correctly when we put in the base class place every derived class. How to use the LSP principle in practice?  Think carefully before taking advantage of the inheritance. Usually, a better option is to use composition. Try to do a simple experiment:  put in the classes using our… Read More »

EO as Exercises of Open/closed principle

By Karol Bocian | March 6, 2020

Open/closed principle All classes should be open for enlargement and closed for modifications. How to use OCP in practice? You should use interfaces and abstraction, not to become dependent on implementation details. Difficulties in using OCP Sometimes is hard to decide, what is implementing detail and in which direction the application is going.  Example To exercises… Read More »

ES as Exercises of Single responsibility principle

By Karol Bocian | March 14, 2020

Single responsibility principle Each class should have only one responsibility (one reason to change) — one purpose of existence. How to use the SRP principle in practice?  Combine into one code, which has the same reason to change. Separate a code that has many reasons to change. Difficulties with SRP There are some difficulties with… Read More »