OOP — Object Oriented Programming

By | 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 | 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 | 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 | 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 | 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 | 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 | 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 »

Composition Over Inheritance

By | February 27, 2020

Composition Over Inheritance The principle says, that we should prefer composition (class A uses class B) than inheritance. When using inheritance, remember not to break the Liskov Substitution Principle. The principle does not say that we should completely reject inheritance. Example: We have a Worker and a Manager. Inheritance: Both classes have names and surname.… Read More »

KISS — Keep it simple, stupid

By | February 24, 2020

The KISS rule recommends creating a solution in the simplest way possible. It is recommended to maintain an elegant, simple structure without oddities and unnecessary elements, and avoid overgrowing the form over the content. Its use is aimed at facilitating understanding of the solution, its subsequent maintenance, and development, e.g. a computer program. All posts… Read More »

L jak Liskov Substitution Principle

By | February 21, 2020

Liskov Substitution Principle The application should work correctly when we put in the base class place every derived class. There is required full interface and method compatibility. You should remember, during designing class hierarchy, that every class can use their method from base class without overriding them. Methods of derivative classes should at most extend… Read More »

O as Open-closed principle

By | February 19, 2020

Open/closed principle All classes should be open for enlargement and closed for modifications. This principle is about two things: Open — Elements should be created in a way to be easily expanded. Changes in their behavior should not require modification of the current code but added a new one. Closed — Behavior modification should not be… Read More »

SOLID exercises — Kata

By | February 17, 2020

Today I practised SOLID by making Kata. I choosed very popular Kata: The String calculator. Do you know what Kata is? Kata Kata is a basic motion. It is a Japanese word, which describe specific motion sequence (fight moves). Regular Kata repetitions allow you to practice to perfection in your chosen technique. In programming, Kata… Read More »

S like Single responsibility principle

By | February 15, 2020

Single responsibility principle Every class should have only one reason to change. Every class should have: Only one goal of existence. Only one responsibility. Only one task to do. Only one reason for the modification. This rule can be applied to methods, functions, classes, modules and packages.   Advantages More readable code. More understandable code.… Read More »