Here is a book that takes the sting out of learning object-oriented design patterns! Using vignettes from the fictional world of Harry Potter, author Avinash C. Kak provides a refreshing alternative to the typically abstract and dry object-oriented design literature.

Designing with Objects is unique. It explains design patterns using the short-story medium instead of sterile examples. It is the third volume in a trilogy by Avinash C. Kak, following Programming with Objects (Wiley, 2003) and Scripting with Objects (Wiley, 2008). Designing with Objects confronts how difficult it is for students to learn complex patterns based on conventional scenarios that they may not be able to relate to. In contrast, it shows that stories from the fictional world of Harry Potter provide highly relatable and engaging models. After explaining core notions in a pattern and its typical use in real-world applications, each chapter shows how a pattern can be mapped to a Harry Potter story. The next step is an explanation of the pattern through its Java implementation. The following patterns appear in three sections: Abstract Factory, Builder, Factory Method, Prototype, and Singleton; Adapter, Bridge, Composite, Decorator, Facade, Flyweight, and Proxy; and the Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, and Visitor. For readers' use, Java code for each pattern is included in the book's companion website.

  • All code examples in the book are available for download on a companion website with resources for readers and instructors.
  • A refreshing alternative to the abstract and dry explanations of the object-oriented design patterns in much of the existing literature on the subject.
  • In 24 chapters, Designing with Objects explains well-known design patterns by relating them to stories from the fictional Harry Potter series



Autorentext

Avinash C. Kak is Professor of Electrical and Computer Engineering at Purdue University. His areas of interest include software engineering, computer and network security, sensor networks, and computer vision (especially with camera networks). Professor Kak has been awarded numerous Best Teacher of the Year awards at Purdue University. He is the author of Scripting with Objects and Programming with Objects, both published by Wiley.



Inhalt

PREFACE xiv

ACKNOWLEDGMENTS xix

1 Why Learn Design Patterns and Why Do So with Help from Harry Potter? 1

1.1 The OO Design Patterns "Bible" by GoF 2

1.2 But What Has Harry Potter Got to Do with OO Design Patterns? 4

1.3 Is Familiarity with Harry Potter a Requirement for Understanding This Book? 6

1.4 How the Pattern Explanations are Organized 7

1.5 The Terminology of Object-Oriented Programming 7

1.6 The UML Notation Used in the Class Diagrams 12

1.6.1 Association as a Relationship Between Classes 14

1.6.2 Aggregation and Composition as Relationships Between Classes 15

1.6.3 Representing Attributes 16

1.6.4 Representing Operations 17

I CREATIONAL PATTERNS 19

2 Abstract Factory 21

2.1 The Concept of a Factory in Software 21

2.2 Intent and Applicability 22

2.3 Introduction to the Abstract Factory Pattern 22

2.4 The Abstract Factory Pattern in Real-World Applications 23

2.5 Harry Potter Story Used to Illustrate the Abstract Factory Pattern 23

2.6 A Top Level View of the Pattern Demonstration 25

2.7 The Abstract Class Factory 27

2.8 The Helper Class FactoryStore 27

2.9 The Abstract Class Enchanted 30

2.10 The Concrete Classes for Magical Objects 31

2.11 The Concrete Factory Classes 32

2.12 The Client Class Diagon AlleyRetailer 34

2.13 Playing with the Code 36

3 Builder 38

3.1 Building Complex Objects 38

3.2 Intent and Applicability 39

3.3 Introduction to the Builder Pattern 39

3.4 The Builder Pattern in Real-World Applications 41

3.5 Harry Potter Story Used to Illustrate the Builder Pattern 42

3.6 A Top-Level View of the Pattern Demonstration 43

3.7 The Abstract Class PotionMaker 45

3.8 The Concrete Extensions of PotionMaker 46

3.9 The Director Class 52

3.10 The Potion Class 54

3.11 The Ingredient Class 55

3.12 The PotionMakingFeasibilityViolation Class 55

3.13 The Client Class 55

3.14 Playing with the Code 56

4 Factory Method 59

4.1 Revisiting the Concept of a Factory in Software 59

4.2 Intent and Applicability 60

4.3 Introduction to the Factory Method Pattern 60

4.4 The Factory Method Pattern in Real-World Applications 61

4.5 Harry Potter Story Used to Illustrate the Factory Method Pattern 62

4.6 A Top Level View of the Pattern Demonstration 63

4.7 The Enchanted Class Hierarchy 65

4.8 The ArtifactFactory Class Hierarchy and the Factory Methods Contained Therein 68

4.9 The Client Class 70

4.10 Playing with the Code 71

5 Prototype 73

5.1 Why Not Make New Objects by Copying Old Objects? 73

5.2 Intent and Applicability 74

5.3 Introduction to the Prototype Pattern 74

5.4 The Prototype Pattern in Real-World Applications 77

5.5 Harry Potter Story Used to Illustrate The Prototype Pattern 78

5.6 A Top Level View of the Pattern Demonstration 79

5.7 The Dragon Class 81

5.8 The PrototypeManagerAndDuplicator Class 84

5.9 The DragonAficionado Class 87

5.10 The UnknownDragonException Class 88

5.11 Playing with the Code 88

6 Singleton 90

6.1 Singular Objects 90

6.2 Intent and Applicability 90

6.3 Introduction to the Singleton Pattern 91

6.4 The Singleton Pattern in Real-World Applications 91

6.5 Harry Potter Story Used to Illustrate the Singleton Pattern 92

6.6 A Top Level View of the Pattern Demonstration 92

6.7 The MinisterForMagic Class 93

6.8 The TestSingleton Class 94

6.9 Variations on the Singleton Pattern 95

6.10 Playing with the Code 97

II STRUCTURAL PATTERNS 99

7 Adapter 101

7.1 Getting Things to Work Together 101

7.2 Intent and Applicability 102

7.3 Introduction to the Adapter Pattern 102

7.4 The Adapter Pattern in Real-World Applications 103

7.5 Harry Potter Story Used to Illustrate the Adapter Pattern 104

7.6 A Top Level View of the Pattern Demonstration 104

7.7 The Target Interface: TeachingDADA 106

7.8 The TeacherForDADA Class 107

7.9 The AdapterForSafeTeaching Class 108

7.10 The Client Class SchoolOfMagic 110

7.11 Object Adapter 111

7.12 Pluggable Adapter 113

7.13 Playing with the Code 119

8 Bridge 122

8.1 Concepts and Their Implementation 122

8.2 Intent and Applicability 123

8.3 Introduction to the Bridge Pattern 123

8.4 The Bridge Pattern in Real-World Applications 126

8.5 Harry Potter Story Used to Illustrate the Bridge Pattern 127

8.6 A Top Level View of the Pattern Demonstration 130

8.7 The Humanoid Class 130

8.8 The Dementor, Goblin, and HouseElf Classes 132

8.9 The Humanoid Imp Class 134

8.10 Implementation Classes for the Dementor, Goblin, and HouseElf Classes 137

8.11 The Client Class MinistryOfMagic 139

8.12 Playing with the Code 140

9 Composite 142

9.1 Relationships That Loop Back 142

9.2 Intent and Applicability 143

9.3 Introduction to the Composite Pattern 144

9.4 The Composite Pattern in Real-World Applications 145

9.5 Harry Potter Story Used to I…

Titel
Designing with Objects
Untertitel
Object-Oriented Design Patterns Explained with Stories from Harry Potter
EAN
9781118903421
ISBN
978-1-118-90342-1
Format
E-Book (pdf)
Hersteller
Herausgeber
Veröffentlichung
15.12.2014
Digitaler Kopierschutz
frei
Dateigrösse
6.08 MB
Anzahl Seiten
507
Jahr
2014
Untertitel
Englisch