
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 connected with changes in existing code.
This rule we can use in methods, functions, classes, modules and packages. To apply this principle, we can use Single responsibility Principle and Dependency inversion principle.
Advantages
- Greater flexibility.
- Greater code reuse.
- Easier maintenance.
- Easier application improvement.
- Backward compatibility.
Disadvantages
- Greater difficulty and labor consumption during software development.
Example
- Calculator, which counts figures area. It iterates figures. Every figure implements IFigure interface. This calculator call on every figure the method GetArea(), instead of has a switch and calculate in Calculator every area.
- Report generators create different reports. Report generators implement IReportGenerates. We can put this report generators in clients depend on client specifications (for instance they want Pdf, Html).
All posts from mini project: Learn SOLID and OOP principles:
- SOLID
- 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
Sources
Main image
Materials
- Clean architecture — Robert C. Martin
- https://sii.pl/blog/solid-dobre-praktyki-programowania/
- https://javadeveloper.pl/solid/
- http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod
- https://www.p-programowanie.pl/paradygmaty-programowania/zasady-solid/
- https://www.samouczekprogramisty.pl/solid-czyli-dobre-praktyki-w-programowaniu-obiektowym/
- https://pl.wikipedia.org/wiki/Zasada_otwarte-zamkni%C4%99te
- https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle
- The Open-Closed Principle – Robert C. Martin – https://drive.google.com/file/d/0BwhCYaYDn8EgN2M5MTkwM2EtNWFkZC00ZTI3LWFjZTUtNTFhZGZiYmUzODc1/view
1
/
30


Okienko w Liście - Group Focus in a Repeating Group| Bubble.io TUTORIAL

Tooltip | Bubble.io Quick Tip

Dodawanie i Pobieranie Plików - Upload and Download File | Bubble.io TUTORIAL

2 Kolumnowe Okienko Logowania - 2 Column Login Popup| Bubble.io Quick Tip

KB_ZW_0151 - Refleksje Na Temat Zarządzania Wiedzą: Przepływ

Dynamiczny formularz - Dynamic Form| Bubble.io Quick Tip

Przeglądanie PDFów - PDF File System| Bubble.io Quick Tip

Generowanie PDFa - Create PDFs| Bubble.io TUTORIAL

Zaproszenia do Zespołu - Team Invitations| Bubble.io TUTORIAL

Role Użytkowników - Visibility by User Roles| Bubble.io TUTORIAL

Generowanie SHA256 - Hash Text in SHA256| Bubble.io Quick Tip

KB_ZW_0150 - Refleksje Na Temat Zarządzania Wiedzą: Działanie

Przyciski udostępniania| Bubble.io TUTORIAL

Powiadomienia - Notifications| Bubble.io TUTORIAL

Strona profilowa - Profile Page| Bubble.io TUTORIAL

Wgrywanie Wielu Zdjęć - Picture Uploadin| Bubble.io TUTORIAL

Unikalność Loginów - Check If A Username Is Taken| Bubble.io Quick Tip

Dwa Dropdowny Wykluczające Się z Wartościami Domyślnymi| Bubble.io TUTORIAL

Dwa Dropdowny Wykluczające Się| Bubble.io TUTORIAL

Pełna lista w Repeating Group - Repeating Group Full List| Bubble.io Quick Tip

Przezroczyste tło nagłówka - Transition Header Background| Bubble.io TUTORIAL

KB_ZW_0149 - Refleksje Na Temat Zarządzania Wiedzą: Najważniejsze

Kopiowanie tekstu do schowka - Copy Text to Clipboard| Bubble.io Quick Tip

Kopiowanie elementów do inne aplikacji - Copy elements| Bubble.io Quick Tip

Automatyczne Wylogowywanie - Automatically Log an Inactive User Out| Bubble.io Quick Tip

Przetwarzanie danych w Popupie - Processing Data in Popups| Bubble.io TUTORIAL

Gra Wordle - Build Wordle| Bubble.io TUTORIAL BUDOWA APLIKACJI

Naucz się Tworzyć Aplikacje - Learn to Build Apps| Bubble.io TUTORIAL

Filtrowanie mnniejszych i większych niż - Filtering by Greater & Less Than| Bubble.io Quick Tip

KB_ZW_0148 - Refleksje Na Temat Zarządzania Wiedzą: Poranki
1
/
30
