Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mohamed-adel23/design-principles
The explanation of design principles specifically focusing on SOLID Principles.
https://github.com/mohamed-adel23/design-principles
Last synced: 2 days ago
JSON representation
The explanation of design principles specifically focusing on SOLID Principles.
- Host: GitHub
- URL: https://github.com/mohamed-adel23/design-principles
- Owner: Mohamed-Adel23
- Created: 2024-04-17T13:47:47.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-04-26T19:20:22.000Z (9 months ago)
- Last Synced: 2024-11-28T09:16:55.952Z (2 months ago)
- Language: C#
- Size: 290 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Design Principles
## What are Design Principles? đ¨
Abstract (High-Level) guidelines, suitable to all programming languages, to improve the object-oriented design of the software to be produced in a high quality,
so the code becomes more *maintainable*, *flexible*, *reusable*, and *extensible*.
> Here, in this repository I will discuss and explain **SOLID** principles with UML diagrams and snippets of codes to make the principle easy to understand.## Prerequisites â
- You should have a good understanding of **Object-Oriented Programming OOP** before dig dive into this repository.## Some Terms To Understand Before Getting Strated đ
### [1] Encapsulate What varies:
The **Encapsulate What Varies** principle is a design guideline in software engineering that advocates encapsulating the parts of a system that are likely to change.
It is one of the key principles of the *SOLID principles*, specifically associated with the "Open/Closed Principle" (OCP).**The logic is:** The code that keeps changing, candidate to be highly reused, therefore this may cause ***inconsistency*** in the code and the code will break the ***DRY(Don't Repeat Yourself)*** concept, so we should encapsulate what varies.
**Problems We Faced Without Applying This Concept**
- Breaking DRY (Don't Repeat Yourself) concept
- Difficult to extend a method
- Data inconsistency**Advantages of Using This Concept**
- Respect DRY concept
- Easy to extend a Method
- Respect (Open/Closed Principle (OCP))**Example:** You're tasked to design a system for a Pizza Restaurant which has different types of pizza đ
***Bad Design*** âšī¸
![1](https://github.com/Mohamed-Adel23/Design-Principles/assets/119868046/93ca9949-07e4-4910-b7b2-5a45e00c2748)
Here we have a method called (Order) which recieve the type of pizza and comparing it with the existing types (variable code) and then Prepare, Cook and Cut the pizza and finally returning it. the problem here is there is a variable code with constant one, which should be isolated (encapsulated) to avoid duplication, incosistency, ... etc
***Good Design*** đ
![2](https://github.com/Mohamed-Adel23/Design-Principles/assets/119868046/ea5b6814-2594-4c24-87d4-e9e5be41feb0)
Here we isolate the variable code in the (Create) Method which will create the Pizza based on the given type, so we managed to avoid many problems.
### [2] Inheritence VS Composition
## Resources đ
- [x] [Eng. Essam Abdelnabi](https://youtube.com/playlist?list=PL4n1Qos4Tb6ThSyydEJTm7xJ3qEwE8Oyu&si=fx9eoLqGwhnXSO9f)
- [x] [ChatGPT](https://chat.openai.com/)