Transcription of The GoF Design Patterns Reference
1 The GoF Design Patterns ReferenceVersion / / Generated 2014-2018 w3sDesign. All rights GoF Design Patterns Referencew3sDesign / V / of ContentsPreface .. viiiI. Introduction .. 11. Design PRINCIPLES .. 22. OVERVIEW .. 7II. Creational Patterns .. 111. ABSTRACT FACTORY .. 12 Intent .. 12 Problem .. 13 Solution .. 14 Motivation 1 .. 16 Applicability .. 17 Structure, Collaboration .. 18 Consequences .. 19 Implementation .. 20 Sample Code 1 .. 21 Sample Code 2 .. 24 Sample Code 3 .. 26 Related Patterns .. 282. BUILDER .. 29 Intent .. 29 Problem .. 30 Solution .. 31 Motivation 1 .. 32 Applicability .. 33 Structure, Collaboration .. 34 Consequences .. 35 Implementation .. 36 Sample Code 1 .. 37 Related Patterns .. 393. FACTORY METHOD .. 40 Intent .. 40 Problem .. 41 Solution .. 42 Motivation 1 .. 43 Applicability .. 44 Structure, Collaboration .. 46 Consequences .. 47 Implementation.
2 48 Sample Code 1 .. 50 Sample Code 2 .. 52 Related Patterns .. 534. PROTOTYPE .. 54 Intent .. 54 Problem .. 55 Solution .. 56 Motivation 1 .. 57 Applicability .. 58 Structure, Collaboration .. 59 Consequences .. 60 Implementation .. 61 Sample Code 1 .. 62 Sample Code 2 .. 64 Related Patterns .. 66 The GoF Design Patterns Referencew3sDesign / V / SINGLETON .. 67 Intent .. 67 Problem .. 68 Solution .. 69 Motivation 1 .. 70 Applicability .. 71 Structure, Collaboration .. 72 Consequences .. 73 Implementation .. 74 Sample Code 1 .. 75 Related Patterns .. 76 III. Structural Patterns .. 771. ADAPTER .. 78 Intent .. 78 Problem .. 79 Solution .. 80 Motivation 1 .. 81 Applicability .. 82 Structure, Collaboration .. 83 Consequences .. 84 Implementation .. 85 Sample Code 1 .. 86 Sample Code 2 .. 88 Related Patterns .. 892. BRIDGE .. 90 Intent .. 90 Problem .. 91 Solution.
3 92 Motivation 1 .. 93 Applicability .. 94 Structure, Collaboration .. 95 Consequences .. 96 Implementation .. 97 Sample Code 1 .. 98 Related Patterns .. 993. COMPOSITE .. 100 Intent .. 100 Problem .. 101 Solution .. 102 Motivation 1 .. 104 Applicability .. 105 Structure, Collaboration .. 106 Consequences .. 107 Implementation .. 108 Sample Code 1 .. 109 Sample Code 2 .. 111 Related Patterns .. 1134. DECORATOR .. 114 Intent .. 114 Problem .. 115 Solution .. 116 Motivation 1 .. 117 Applicability .. 118 Structure, Collaboration .. 119 Consequences .. 120 The GoF Design Patterns Referencew3sDesign / V / .. 121 Sample Code 1 .. 122 Sample Code 2 .. 124 Related Patterns .. 1255. FACADE .. 126 Intent .. 126 Problem .. 127 Solution .. 128 Motivation 1 .. 129 Applicability .. 130 Structure, Collaboration .. 131 Consequences .. 132 Implementation .. 133 Sample Code 1.
4 134 Related Patterns .. 1366. FLYWEIGHT .. 137 Intent .. 137 Problem .. 138 Solution .. 139 Motivation 1 .. 140 Applicability .. 141 Structure, Collaboration .. 142 Consequences .. 144 Implementation .. 145 Sample Code 1 .. 146 Related Patterns .. 1487. PROXY .. 149 Intent .. 149 Problem .. 150 Solution .. 151 Motivation 1 .. 152 Applicability .. 153 Structure, Collaboration .. 154 Consequences .. 155 Implementation .. 156 Sample Code 1 .. 157 Related Patterns .. 158IV. Behavioral Patterns .. 1591. CHAIN OF RESPONSIBILITY .. 160 Intent .. 160 Problem .. 161 Solution .. 162 Motivation 1 .. 163 Applicability .. 164 Structure, Collaboration .. 165 Consequences .. 166 Implementation .. 167 Sample Code 1 .. 168 Related Patterns .. 1702. COMMAND .. 171 Intent .. 171 Problem .. 172 Solution .. 173 Motivation 1 .. 174 Applicability .. 175 The GoF Design Patterns Referencew3sDesign / V / , Collaboration.
5 176 Consequences .. 177 Implementation .. 178 Sample Code 1 .. 179 Related Patterns .. 1813. INTERPRETER .. 182 Intent .. 182 Problem .. 183 Solution .. 184 Motivation 1 .. 186 Applicability .. 187 Structure, Collaboration .. 188 Consequences .. 189 Implementation .. 190 Sample Code 1 .. 192 Sample Code 2 .. 194 Related Patterns .. 1984. ITERATOR .. 199 Intent .. 199 Problem .. 200 Solution .. 201 Motivation 1 .. 202 Applicability .. 203 Structure, Collaboration .. 204 Consequences .. 205 Implementation .. 206 Sample Code 1 .. 207 Sample Code 2 .. 209 Related Patterns .. 2135. MEDIATOR .. 214 Intent .. 214 Problem .. 215 Solution .. 216 Motivation 1 .. 217 Applicability .. 218 Structure, Collaboration .. 219 Consequences .. 220 Implementation .. 221 Sample Code 1 .. 222 Related Patterns .. 2256. MEMENTO .. 226 Intent .. 226 Problem .. 227 Solution .. 228 Motivation 1.
6 229 Applicability .. 230 Structure, Collaboration .. 231 Consequences .. 232 Implementation .. 233 Sample Code 1 .. 234 Related Patterns .. 2367. OBSERVER .. 237 Intent .. 237 Problem .. 238 Solution .. 239 The GoF Design Patterns Referencew3sDesign / V / 1 .. 240 Applicability .. 241 Structure, Collaboration .. 242 Consequences .. 243 Implementation .. 244 Sample Code 1 .. 245 Sample Code 2 .. 247 Sample Code 3 .. 249 Sample Code 4 .. 252 Related Patterns .. 2548. STATE .. 255 Intent .. 255 Problem .. 256 Solution .. 257 Motivation 1 .. 258 Applicability .. 259 Structure, Collaboration .. 260 Consequences .. 261 Implementation .. 262 Sample Code 1 .. 263 Sample Code 2 .. 265 Related Patterns .. 2679. STRATEGY .. 268 Intent .. 268 Problem .. 269 Solution .. 270 Motivation 1 .. 272 Applicability .. 273 Structure, Collaboration .. 275 Consequences .. 276 Implementation.
7 277 Sample Code 1 .. 278 Sample Code 2 .. 280 Sample Code 3 .. 283 Related Patterns .. 28910. TEMPLATE METHOD .. 291 Intent .. 291 Problem .. 292 Solution .. 293 Motivation 1 .. 294 Applicability .. 295 Structure, Collaboration .. 296 Consequences .. 297 Implementation .. 298 Sample Code 1 .. 299 Sample Code 2 .. 300 Related Patterns .. 30111. VISITOR .. 302 Intent .. 302 Problem .. 303 Solution .. 304 Motivation 1 .. 305 Applicability .. 306 Structure, Collaboration .. 307 Consequences .. 308 The GoF Design Patterns Referencew3sDesign / V / .. 309 Sample Code 1 .. 310 Sample Code 2 .. 312 Related Patterns .. 317V. GoF Design Patterns Update .. 3181. DEPENDENCY INJECTION .. 319 Intent .. 319 Problem .. 320 Solution .. 321 Motivation 1 .. 322 Applicability .. 323 Structure, Collaboration .. 324 Consequences .. 325 Implementation .. 326 Sample Code 1 .. 327 Related Patterns .
8 329A. Bibliography .. 330 Prefacew3sDesign / V / software engineering, Design Patterns describe how to solve recurring Design problems todesign flexible and reusable object-oriented presents the up-to-date version of the well-known GoF Design Patterns in a compactand memory friendly way so that they can be learned and memorized as fast as use a simple and consistent language and repeat important phrases whenever a picture is worth a thousand words, each section of each Design pattern starts with UMLdiagrams to quickly communicate the key aspects of the Design under Design Patterns that are widely used today but not included in the original twenty-three GoFdesign Patterns will be added. This release starts with the Dependency Injection Design pattern,and others will follow in next working through individual Design Patterns , you will learn how to Design objects that areeasier to implement, change, test, and , ready-to-run code samples show how to implement Design Patterns by using object-oriented programming languages such as w3sDesign you will find all you need to know, and you will get the skills that softwaredevelopers need 's all for free, and it's pretty fast.
9 Enjoy it! Design Patterns : Elements of Reusable Object-Oriented Software. Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides. Published October 1994. Copyright 1995 by Addison-Wesley. (The authors of the book are commonly referred to as "GoF" or "Gang of Four".)Introductionw3sDesign / V / I. IntroductionDESIGN PRINCIPLESw3sDesign / V / PRINCIPLESw3sDesign / V / PRINCIPLESw3sDesign / V / PRINCIPLESw3sDesign / V / PRINCIPLESw3sDesign / V / / V / / V / / V / / V / Patternsw3sDesign / V / II. Creational PatternsABSTRACT FACTORYw3sDesign / V / intent of the Abstract Factory Design pattern is to:"Provide an interface for creating families of related or dependent objectswithout specifying their concrete classes." [GoF]See Problem and Solution sections for a more structured description of the intent. The Abstract Factory Design pattern solves problems like: How can a class be independent of how the objects it requires are created?
10 How can different families of related or dependent objects be created? An inflexible way is to create objects directly within the class (Client) that requires the commits the class to particular objects and makes it impossible to change the instantiationlater independently from (without changing) the class. The Abstract Factory pattern describes how to solve such problems: Provide an interface for creating families of related or dependent objectswithout specifying their concrete classes:AbstractFactory | createProductA(),createProductB(),.. The process of object creation (new ProductA1(), for example) is abstracted by referringto an interface (delegating to a factory object): ().There is no longer anything in the client code that instantiates a concrete FACTORYw3sDesign / V / Abstract Factory Design pattern solves problems like:How can a class be independent of how the objects it requires are created?How can different families of related or dependent objects be created?