Mais conteúdo relacionado



Design patterns

  1. Design Patterns for software engineering Presented by: Rohan Jain Tanisha Bhayani Akshay Bhanderi Abhay Desale
  2. What is design pattern? ● Design patterns are typical solutions to commonly occurring problems in software design. ● They are like pre-made blueprints that you can customize to solve a recurring design problem in your code. ● Types of design pattern ○ Creational Design Patterns ○ Structural Design Patterns ○ Behavioral Design Patterns
  3. Creational Design Pattern: Factory Method we create object without exposing the creation logic to client and the client use the same common interface to create new type of object
  4. Creational Design Pattern:Abstract Factory Lets you produce families of related objects without specifying their concrete classes.
  5. Creational Design Pattern: Builder ● That lets you construct complex objects step by step. ● The pattern allows you to produce different types and representations of an object using the same construction code.
  6. Creational Design Pattern: Singleton class Database is private static field instance: Database private constructor Database() is public static method getInstance() is if (Database.instance == null) then acquireThreadLock() and then if (Database.instance == null) then Database.instance = new Database() return Database.instance public method query(sql) is class Application is method main() is Database foo = Database.getInstance() foo.query("SELECT ...") // ... Database bar = Database.getInstance() bar.query("SELECT ...") // The variable `bar` will contain the same object as // the variable `foo`. That lets you ensure that a class has only one instance, while providing a global access point to this instance.
  7. Creational Design Pattern: Prototype lets you copy existing objects without making your code dependent on their classes.
  8. Structure Design Pattern: Adapter Pattern Scenario: Two incompatible interfaces but the core functionality is same. Class Adapter - Inheritance Object Adapter - Delegation through Composition
  9. Structure Design Pattern: Bridge Pattern Scenario: Vary the implementation and the abstraction by placing the two into separate class hierarchies.
  10. Structure Design Pattern: Composite Pattern Scenario: When clients ignore the difference between compositions of objects and individual objects.
  11. Structure Design Pattern: Decorator Pattern Scenario: Allows behavior to be added to an individual object, dynamically, without affecting the behavior of other objects from the same class.
  12. Structure Design Pattern: Facade Pattern Scenario: The client facing interface needs simplification.
  13. Structure Design Pattern: Flyweight Pattern Scenario: Minimize memory usage or computational expenses by sharing as much as possible with similar objects.
  14. Structure Design Pattern: Proxy Pattern Scenario: When client needs to protect, hide complexity, or delay expensive actions.
  15. Anti Pattern ● Applying a particular design pattern in the improper context.
  16. Behaviour Pattern ● Behavioral design patterns are concerned with the interaction and responsibility of objects. Behaviour Design Pattern: Chain of Responsibility What it suggests? Pass the request along the chain of handlers instead of one. Control order of request handling
  17. Behaviour Design Pattern: Command What is suggets? Turns a request into a stand-alone object that contains all information about the request.
  18. Behaviour Design Pattern: Iterator What is suggets? lets you traverse elements of a collection without exposing its underlying representation
  19. Behaviour Design Pattern: Meditor What is suggets? This pattern restricts direct communications between the objects and forces them to collaborate only via a mediator object. Increases reusability
  20. Behaviour Design Pattern: Template Method What it says? Just define the skeleton of a function in an operation, deferring some steps to its subclasses. Remove duplication
  21. Behaviour Design Pattern: Visitor What is says? Visitor lets you define a new operation without changing the classes of the elements on which it operates.
  22. Behaviour Design Pattern: Memento Lets you save and restore the previous state of an object without revealing the details of its implementation.
  23. Behaviour Design Pattern: Observer Lets you define a subscription mechanism to notify multiple objects about any events that happen to the object they’re observing.
  24. Behaviour Design Pattern: State Lets an object alter its behavior when its internal state changes. It appears as if the object changed its class.
  25. Behaviour Design Pattern: Strategy Lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable. Problem Solution
  26. References ● ● ● ● (for visiter) ● ● ● ● Pattern Series) ● ● ● ● adapter-pattern ● ● ● ● ●
  27. Thank You Any Question?