Ten Most Commonly Used Design Patterns

xiaoxiao2021-03-05  25

1. The Facade Pattern Provide a Unified Interface To a set of interfaces in a subsystem. It defines a higher-level interface That Makes The Subsystem Easier To Use.

ONLY WORKS WHEN: 1.USE A Subset of The System's Capabilities 2.INTERACT with IT IN A Particular Way

Variations: 1.Reduce The Number of Objects a Client Must Work with 2.Provide New Functions 3.hide The System

2. The Adapter Pattern Convert The Interface of a Class Into Another Interface That The Clients Expect.it Lets Classes Work Together That Could Not OtherWise Because of Incompatible Interfaces.

.................. ..

How to use: 1.define the interface and then implement in derived classes 2.the derived class contains the existing class which to be used but has wrong interface, then passes request made to it on through to that class It frees you from worrying about EXISTING INTERFCES.

Two Types: 1.Object Adapter Pattern - IT Relies on One Object Containing Another. 2.Class Adapter Pattern - Implement Useing Multiple Inheritance

Difference: a Facade Simplifies An Interface While An Adapter Converts The Interface Into a PreexiSting Interface.

3. The Bridge Pattern De-couple an abstraction from its implementation so that the two can vary independently -. This pattern is a bit hard to understand at first But it is a challenging pattern to learn cause it is so powerful **!. * Implementation Here Means The Objects That The Abstract Class and ITS Derivations Use To Implement The Abstract Class, Which Are Called Concrete Classes.

.! You cant always see the variations at the beginning of the problem Bottom line: During requirements definition, explore for variations early and often It is more useful to focus on the context of the pattern - the problem it is trying to solve.This lets you know when and why to use it you can identify when to apply a pattern before knowing exactly how to implement it The bridge pattern is useful when:... you have an abstraction that has different implementations It allows the abstraction and the implementation to vary Independently of Each Other.

Commonality / Variability analysis: Commonality - the search for common elements that helps us understand how family members are the same.Thus, the process of finding out how things are common defines the family in which these elements belong (where things vary) It seeks. Structure That. Variability - Reveals How Family Members Vary.it Only Makes Sense Within a Given Commonality. It Captures Structure That Is Likey to Change.

IT IS Suggested That Using CommonAlicity / Variability Analysis As A Primary Tool In Creating Objects IS A Better Approach Than Looking At Just Nouns and Verbs.

转载请注明原文地址:https://www.9cbs.com/read-38320.html

New Post(0)