JS Design patterns in Web technologies including oop techniques.pptx
husnainali397602
11 views
12 slides
Jun 04, 2024
Slide 1 of 12
1
2
3
4
5
6
7
8
9
10
11
12
About This Presentation
web technology js design patterns
Size: 162.5 KB
Language: en
Added: Jun 04, 2024
Slides: 12 pages
Slide Content
Presentation
Topic: JS Design Patterns
Content: Intro to Design Patterns What is a Design Patterns ? Why to Study Design Patterns? Gang Of Four Singleton Design Pattern Observer Design Pattern Factory Design Pattern
What is a Design Pattern? Design patterns areĀ reusable solutions to commonly occurring problems in software design . They are proven solutions, easily reusable and expressive. They lower the size of your codebase, prevent future refactoring, and make your code easier to understand by other developers.
Why study design pattern? Design patterns are a toolkit of tried and tested solutions to common problems in software design. Even if you never encounter these problems, knowing patterns is still useful becauseĀ it teaches you how to solve all sorts of problems using principles of object-oriented design .
The Gang of Four Three different design patterns: Creational: Creating objects in a manner that is suitable for the situation Structural: Ease the design by identifying a simple way to realize relationship between the entities Behavioral: Common communication patterns between objects
The Gang of Four Creational Abstract Factory Builder Factory Method Prototype Singleton 2. Structural Adapter Bridge Composite Decorator Facade Flyweight Proxy 3. Behavioural Chain of Responsibility Command Interpreter Iterator Mediator Memento Observer State Strategy Template Method Visitor
Singleton Pattern The Singleton method or Singleton Design pattern is one of the simplest design patterns. It ensures a class only has one instance, and provides a global point of access to it.
When to use Singleton Method Design Pattern? Use the Singleton method Design Pattern when: There must be exactly one instance of a class and it must be accessible to clients from a well-known access point. When the sole instance should be extensible by subclassing and clients should be able to use an extended instance without modifying Singleton classes are used for logging, driver objects, caching, and thread pool, database connections
Factory Method
When to useFactory Design Pattern When a class doesn't know what sub-classes will be required to create When a class wants that its sub-classes specify the objects to be created. When the parent classes choose the creation of objects to its sub-classes.
Observer The Observer Design Pattern is a behavioral design pattern that defines a one-to-many dependency between objects so that when one object (the subject) changes its state, all its dependents (observers) are notified and updated automatically. In other words, it establishes a mechanism where multiple objects (observers) are interested in the state changes of another object (subject) and are notified whenever that state changes.