GDGoC: BZU - Design Patterns: No More Spaghetti Code
rasheedsrq
7 views
28 slides
Feb 27, 2025
Slide 1 of 28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
About This Presentation
Slides for our Design Patterns Session, for more info: https://gdg.community.dev/events/details/google-gdg-on-campus-birzeit-university-birzeit-palestine-presents-design-patterns-no-more-spaghetti-code/
Size: 19.97 MB
Language: en
Added: Feb 27, 2025
Slides: 28 pages
Slide Content
Design Patterns: No More Spaghetti Code π
What are Design Patterns? Typical solution for occurring problem. Not copy/paste and run. General Concept, not algorithm. Algorithm Design Patterns
Why Design Patterns? Tried and tested solution. Teaches principles of OOD (Object Oriented Design). Common language.
W hen? When your code feels like spaghetti π (hard to read/maintain). When multiple developers need to collaborate (common language). When scaling your app (patterns ensure flexibility).
Every time a class is instantiated, a new object is created Unnecessary memory usage and performance issues Risk of data conflicts when sharing resources Problem
Ensures only one instance of a class is created. The same object is shared across the application. Prevents data conflicts and saves resources. Solution - Singleton
Concurrent Access β Avoids conflicts when multiple processes access the object Global Access Point β A single access point for consistency Single Object β Centralized control and easier management Why Use Singleton?
What NOT to Do: Anti-Patterns π« Monolithic Class: One class doing everything. C opy-Paste Programming: Duplicate code. Pattern Overkill: Using Singleton for everything.