Monthly Archives: February 2020

Composition Over Inheritance

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

SOLID exercises

By Karol Bocian | February 14, 2020

SOLID SOLID principles are basic rules of object-oriented programming. You should not only know them but also practice and use them at work. At first, I remind you of SOLID principles, and then I show you some exercises. Single responsibility principle Every class should have only one responsibility (every class should have only one reason… Read More »

SOLID

By Karol Bocian | February 12, 2020

SOLID SOLID is a basic concept in object-oriented programming. It was introduced by Robert C. Martin, who gathered together five rules in one concept: SOLID. It is an acronym of 5 principles for good object-oriented programming: Single responsibility principle Open/closed principle Liskov substitution principle Interface segregation principle Dependency inversion principle Single responsibility principle Every class… Read More »