Gang of Four Design Patterns
The book which first raised awareness of the concept of design patterns and is still widely cited by any wiki, web site or book on design patterns is Design Patterns book. The four authors, Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides (coll
- PDF / 29,581 Bytes
- 2 Pages / 439.37 x 666.14 pts Page_size
- 66 Downloads / 580 Views
Gang of Four Design Patterns
16.1
Introduction
The book which first raised awareness of the concept of design patterns and is still widely cited by any wiki, web site or book on design patterns is the Design Patterns book. The four authors, Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides (collectively known as the “Gang of Four”, or GoF for short) popularized the patterns concepts and ideals. The patterns in this book are often referred to as GoF Patterns and the book as the GoF Design Patterns book (to distinguish it from various other books with similar titles). The GoF Design Patterns book is a weighty tome in its own right (over 370 pages). It is also focussed on C++ and Smalltalk as the implementation languages. This is not surprising as the book was originally published in 1995 Since then numerous works have considered how these design patterns relate to other languages such as the books written by Mark Grand (Patterns in Java Vol 1 and Patters in java Vol 2). The first of which is essentially the GoF patterns translated in Java. I am performing a similar role in this section of this book for the Scala language.
16.2
GoF Patterns
There are 23 GoF patterns divided into three categories. The categories are “Creational Patterns”, “Structural Patterns” and “Behavioural Patterns”: Creational Patterns These patterns provide guidance on the creation of objects. They help hide the details of the object instantiation form the code that uses those objects. That is they make a system independent of how its objects are created, composed and represented. This leads to high cohesion between the objects and their users, but low couple between the users and the way the objects are created. For example, if I have a Java interface that is implemented by three different classes, then using a Factory pattern I might instantiate one of the three classes J. Hunt, Scala Design Patterns: Patterns for Practical Reuse and Design, DOI 10.1007/978-3-319-02192-8_16, © Springer International Publishing Switzerland 2013
135
136
16
Gang of Four Design Patterns
depending on the current situation. All the user of the object returned needs to know is what interface they all implement. The actual implementation may change each time the factory is used, but this detail is hidden. Structural Patterns Such patterns describe the organization of objects. That is how classes and objects are composed to form larger structures. For example a large department store near where I live, appears form the outside to be a single entity with a very grand frontage. However, behind this frontage is a completely new shop containing various independent stores. This means that as a customer I see form the outside a single and quite grand whole. But form the inside there are multiple smaller shops/brands all working together. This is the essence of the Façade pattern. Behavioural Patterns Behavioural patterns are concerned with organizing managing and assigning responsibilities to objects during execution. That is, the focus on the patterns o
Data Loading...