Designing with Objects - Avinash C. Kak - E-Book

Designing with Objects E-Book

Avinash C. Kak

0,0
74,99 €

oder
-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

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

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 837

Veröffentlichungsjahr: 2014

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



CONTENTS

Cover

Title page

Copyright page

PREFACE

ACKNOWLEDGMENTS

1 WHY LEARN DESIGN PATTERNS AND WHY DO SO WITH HELP FROM HARRY POTTER?

1.1 THE OO DESIGN PATTERNS “BIBLE” BY GoF

1.2 BUT WHAT HAS HARRY POTTER GOT TO DO WITH OO DESIGN PATTERNS?

1.3 IS FAMILIARITY WITH HARRY POTTER A REQUIREMENT FOR UNDERSTANDING THIS BOOK?

1.4 HOW THE PATTERN EXPLANATIONS ARE ORGANIZED

1.5 THE TERMINOLOGY OF OBJECT-ORIENTED PROGRAMMING

1.6 THE UML NOTATION USED IN THE CLASS DIAGRAMS

Part I: CREATIONAL PATTERNS

2 ABSTRACT FACTORY

2.1 THE CONCEPT OF A FACTORY IN SOFTWARE

2.2 INTENT AND APPLICABILITY

2.3 INTRODUCTION TO THE ABSTRACT FACTORY PATTERN

2.4 THE ABSTRACT FACTORY PATTERN IN REAL-WORLD APPLICATIONS

2.5 HARRY POTTER STORY USED TO ILLUSTRATE THE ABSTRACT FACTORY PATTERN

2.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

2.7 THE ABSTRACT CLASS Factory

2.8 THE HELPER CLASS FactoryStore

2.9 THE ABSTRACT CLASS Enchanted

2.10 THE CONCRETE CLASSES FOR MAGICAL OBJECTS

2.11 THE CONCRETE Factory CLASSES

2.12 THE CLIENT CLASS Diagon AlleyRetailer

2.13 PLAYING WITH THE CODE

3 BUILDER

3.1 BUILDING COMPLEX OBJECTS

3.2 INTENT AND APPLICABILITY

3.3 INTRODUCTION TO THE BUILDER PATTERN

3.4 THE BUILDER PATTERN IN REAL-WORLD APPLICATIONS

3.5 HARRY POTTER STORY USED TO ILLUSTRATE THE BUILDER PATTERN

3.6 A TOP-LEVEL VIEW OF THE PATTERN DEMONSTRATION

3.7 THE ABSTRACT CLASS PotionMaker

3.8 THE CONCRETE EXTENSIONS OF PotionMaker

3.9 THE Director CLASS

3.10 THE Potion CLASS

3.11 THE Ingredient CLASS

3.12 THE PotionMakingFeasibilityViolation CLASS

3.13 THE Client CLASS

3.14 PLAYING WITH THE CODE

4 FACTORY METHOD

4.1 REVISITING THE CONCEPT OF A FACTORY IN SOFTWARE

4.2 INTENT AND APPLICABILITY

4.3 INTRODUCTION TO THE FACTORY METHOD PATTERN

4.4 THE FACTORY METHOD PATTERN IN REAL-WORLD APPLICATIONS

4.5 HARRY POTTER STORY USED TO ILLUSTRATE THE FACTORY METHOD PATTERN

4.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

4.7 THE Enchanted CLASS HIERARCHY

4.8 THE ArtifactFactory CLASS HIERARCHY AND THE FACTORY METHODS CONTAINED THEREIN

4.9 THE Client CLASS

4.10 PLAYING WITH THE CODE

5 PROTOTYPE

5.1 WHY NOT MAKE NEW OBJECTS BY COPYING OLD OBJECTS?

5.2 INTENT AND APPLICABILITY

5.3 INTRODUCTION TO THE PROTOTYPE PATTERN

5.4 THE PROTOTYPE PATTERN IN REAL-WORLD APPLICATIONS

5.5 HARRY POTTER STORY USED TO ILLUSTRATE THE PROTOTYPE PATTERN

5.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

5.7 THE Dragon CLASS

5.8 THE PrototypeManagerAndDuplicator CLASS

5.9 THE DragonAficionado CLASS

5.10 THE UnknownDragonException CLASS

5.11 PLAYING WITH THE CODE

6 SINGLETON

6.1 SINGULAR OBJECTS

6.2 INTENT AND APPLICABILITY

6.3 INTRODUCTION TO THE SINGLETON PATTERN

6.4 THE SINGLETON PATTERN IN REAL-WORLD APPLICATIONS

6.5 HARRY POTTER STORY USED TO ILLUSTRATE THE SINGLETON PATTERN

6.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

6.7 THE MinisterForMagic CLASS

6.8 THE TestSingleton CLASS

6.9 VARIATIONS ON THE SINGLETON PATTERN

6.10 PLAYING WITH THE CODE

Part II: STRUCTURAL PATTERNS

7 ADAPTER

7.1 GETTING THINGS TO WORK TOGETHER

7.2 INTENT AND APPLICABILITY

7.3 INTRODUCTION TO THE ADAPTER PATTERN

7.4 THE ADAPTER PATTERN IN REAL-WORLD APPLICATIONS

7.5 HARRY POTTER STORY USED TO ILLUSTRATE THE ADAPTER PATTERN

7.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

7.7 THE TARGET INTERFACE: TeachingDADA

7.8 THE TeacherForDADA CLASS

7.9 THE AdapterForSafeTeaching CLASS

7.10 THE CLIENT CLASS SchoolOfMagic

7.11 OBJECT ADAPTER

7.12 PLUGGABLE ADAPTER

7.13 PLAYING WITH THE CODE

8 BRIDGE

8.1 CONCEPTS AND THEIR IMPLEMENTATION

8.2 INTENT AND APPLICABILITY

8.3 INTRODUCTION TO THE BRIDGE PATTERN

8.4 THE BRIDGE PATTERN IN REAL-WORLD APPLICATIONS

8.5 HARRY POTTER STORY USED TO ILLUSTRATE THE BRIDGE PATTERN

8.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

8.7 THE Humanoid CLASS

8.8 THE Dementor, Goblin, AND HouseElf CLASSES

8.9 THE Humanoid Imp CLASS

8.10 IMPLEMENTATION CLASSES FOR THE Dementor, Goblin, AND HouseElf CLASSES

8.11 THE CLIENT CLASS MinistryOfMagic

8.12 PLAYING WITH THE CODE

9 COMPOSITE

9.1 RELATIONSHIPS THAT LOOP BACK

9.2 INTENT AND APPLICABILITY

9.3 INTRODUCTION TO THE COMPOSITE PATTERN

9.4 THE COMPOSITE PATTERN IN REAL-WORLD APPLICATIONS

9.5 HARRY POTTER STORY USED TO ILLUSTRATE THE COMPOSITE PATTERN

9.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

9.7 THE WizardTraits INTERFACE

9.8 THE Wizard CLASS

9.9 THE Auror CLASS

9.10 THE Obliviator CLASS

9.11 THE DepartmentHead CLASS

9.12 THE Minister For Magic CLASS

9.13 THE CLIENT CLASS Test

9.14 PLAYING WITH THE CODE

10 DECORATOR

10.1 ONION AS A METAPHOR

10.2 INTENT AND APPLICABILITY

10.3 INTRODUCTION TO THE DECORATOR PATTERN

10.4 THE DECORATOR PATTERN IN REAL-WORLD APPLICATIONS

10.5 HARRY POTTER STORY USED TO ILLUSTRATE THE DECORATOR PATTERN

10.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

10.7 THE CoreMessageDeliveryClass CLASS

10.8 THE DECORATOR CLASSES

10.9 THE CLIENT CLASS Test

10.10 PLAYING WITH THE CODE

11 FACADE

11.1 HIDING COMPLEXITY

11.2 INTENT AND APPLICABILITY

11.3 INTRODUCTION TO THE FACADE PATTERN

11.4 THE FACADE PATTERN IN REAL-WORLD APPLICATIONS

11.5 HARRY POTTER STORY USED TO ILLUSTRATE THE FACADE PATTERN

11.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

11.7 THE ABSTRACT ROOT CLASS Facade

11.8 THE Network CLASS

11.9 THE Node, Link, AND Path CLASSES

11.10 THE THREE CONCRETE Facade CLASSES

11.11 TESTING THE DEMONSTRATION CODE

11.12 PLAYING WITH THE CODE

12 FLYWEIGHT

12.1 THE IDEA OF CUSTOMIZED DUPLICATIONS

12.2 INTENT AND APPLICABILITY

12.3 INTRODUCTION TO THE FLYWEIGHT PATTERN

12.4 THE FLYWEIGHT PATTERN IN REAL-WORLD APPLICATIONS

12.5 HARRY POTTER STORY USED TO ILLUSTRATE THE FLYWEIGHT PATTERN

12.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

12.7 THE HeadMasterPortrait CLASS

12.8 THE FlyweightImageStore CLASS

12.9 THE ImageManager CLASS

12.10 THE PortraitBorderChoices CLASS

12.11 THE ImageNotAvailableException CLASS

12.12 THE PortraitMakerAssignment CLASS

12.13 PLAYING WITH THE CODE

12.14 ACKNOWLEDGMENT

13 PROXY

13.1 IS IT ALWAYS NECESSARY TO HAVE THE REAL THING?

13.2 INTENT AND APPLICABILITY

13.3 INTRODUCTION TO THE PROXY PATTERN

13.4 THE PROXY PATTERN IN REAL-WORLD APPLICATIONS

13.5 HARRY POTTER STORY USED TO ILLUSTRATE THE PROXY PATTERN

13.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

13.7 THE ABSTRACT CLASS Wizard

13.8 THE DarkWizardTraits INTERFACE

13.9 THE DarkWizard CLASS

13.10 THE DarkLord CLASS

13.11 THE ClientClass CLASS

13.12 PLAYING WITH THE CODE

Part III: BEHAVIORAL PATTERNS

14 CHAIN OF RESPONSIBILITY

14.1 PASSING THE BUCK

14.2 INTENT AND APPLICABILITY

14.3 INTRODUCTION TO THE CHAIN OF RESPONSIBILITY PATTERN

14.4 THE CHAIN OF RESPONSIBILITY PATTERN IN REAL-WORLD APPLICATIONS

14.5 HARRY POTTER STORY USED TO ILLUSTRATE THE CHAIN OF RESPONSIBILITY PATTERN

14.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

14.7 THE INTERFACE CLASS Violations

14.8 THE ABSTRACT CLASS Adjudicator

14.9 THE Player CLASS

14.10 THE CLASSES WITH THE AUTHORITY TO RESOLVE VIOLATIONS

14.11 TESTING THE CODE

14.12 PLAYING WITH THE CODE

15 COMMAND

15.1 ACTIONS VERSUS THE ACTORS

15.2 INTENT AND APPLICABILITY

15.3 INTRODUCTION TO THE COMMAND PATTERN

15.4 THE COMMAND PATTERN IN REAL-WORLD APPLICATIONS

15.5 HARRY POTTER STORY USED TO ILLUSTRATE THE COMMAND PATTERN

15.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

15.7 THE Command INTERFACE

15.8 THE MyPlaces INTERFACE

15.9 THE ProtectHarryPotter CLASS

15.10 THE Wizard CLASS

15.11 THE Squib CLASS

15.12 THE Invoker CLASS

15.13 THE UnableToProtectHarryPotterException CLASS

15.15 PLAYING WITH THE CODE

16 INTERPRETER

16.1 PARSING VERSUS INTERPRETATION

16.2 INTENT AND APPLICABILITY

16.3 INTRODUCTION TO THE INTERPRETER PATTERN

16.4 THE INTERPRETER PATTERN IN REAL-WORLD APPLICATIONS

16.5 HARRY POTTER STORY USED TO ILLUSTRATE THE INTERPRETER PATTERN

16.6 A PARSER FRONT-END FOR THE INTERPRETER PATTERN

16.7 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

16.8 THE Driver CLASS

16.9 THE Interpreter Sentence CLASS

16.10 THE WORKER CLASSES FOR INTERPRETATION

16.11 THE UTILITY CLASS ShowSyntaxTree

16.12 PLAYING WITH THE CODE

17 ITERATOR

17.1 STORING OBJECT COLLECTIONS AND INTERACTING WITH THEM

17.2 INTENT AND APPLICABILITY

17.3 INTRODUCTION TO THE ITERATOR PATTERN

17.4 THE ITERATOR PATTERN IN REAL-WORLD APPLICATIONS

17.5 HARRY POTTER STORY USED TO ILLUSTRATE THE ITERATOR PATTERN

17.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

17.7 A UTILITY INTERFACE FOR DEMONSTRATING THE ITERATOR PATTERN

17.8 THE Iterator INTERFACE

17.9 THE Fresher CLASS

17.10 THE SortingHat CLASS

17.11 THE MagicCollection INTERFACE

17.12 THE MagicList AND MagicSet CLASSES

17.13 THE CLASS Range

17.14 PLAYING WITH THE CODE

17.15 CREDITS

18 MEDIATOR

18.1 THE ROLE OF MEDIATION IN COLLABORATIVE PROBLEM SOLVING

18.2 INTENT AND APPLICABILITY

18.3 INTRODUCTION TO THE MEDIATOR PATTERN

18.4 THE MEDIATOR PATTERN IN REAL-WORLD APPLICATIONS

18.5 HARRY POTTER STORY USED TO ILLUSTRATE THE MEDIATOR PATTERN

18.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

18.7 THE ABSTRACT CLASS Mediator

18.8 THE INTERFACE TrialElements

18.9 THE MinistryOfMagicTrialMediator CLASS

18.10 THE Witness CLASS

18.11 THE Trial INTERFACE

18.12 THE HarryPotterTrial CLASS

18.13 PLAYING WITH THE CODE

19 MEMENTO

19.1 RECALLING THE PAST

19.2 INTENT AND APPLICABILITY

19.3 INTRODUCTION TO THE MEMENTO PATTERN

19.4 THE MEMENTO PATTERN IN REAL-WORLD APPLICATIONS

19.5 HARRY POTTER STORY USED TO ILLUSTRATE THE MEMENTO PATTERN

19.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

19.7 THE HogwartsHappening CLASS AND THE INNER Memento CLASS

19.8 THE Client CLASS

19.9 PLAYING WITH THE CODE

20 OBSERVER

20.1 SUBSCRIPTION-BASED BROADCASTING

20.2 INTENT AND APPLICABILITY

20.3 INTRODUCTION TO THE OBSERVER PATTERN

20.4 THE OBSERVER PATTERN IN REAL-WORLD APPLICATIONS

20.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

20.7 THE Observer INTERFACE

20.8 THE Observable INTERFACE

20.9 THE DarkLord CLASS

20.10 THE DeathEater CLASS

20.11 THE GodProcess CLASS

20.12 PLAYING WITH THE CODE

21 STATE

21.1 CONTEXTUAL DEPENDENCE OF BEHAVIORS

21.2 INTENT AND APPLICABILITY

21.3 INTRODUCTION TO THE STATE PATTERN

21.4 THE STATE PATTERN IN REAL-WORLD APPLICATIONS

21.5 HARRY POTTER STORY USED TO ILLUSTRATE THE STATE PATTERN

21.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

21.7 THE DADA_State INTERFACE

21.8 THE YEAR-BY-YEAR IMPLEMENTATION CLASSES FOR THE STATE

21.9 THE TeachingDADA CLASS

21.10 THE Hogwarts CLASS

21.11 PLAYING WITH THE CODE

22 STRATEGY

22.1 STRATEGIES IN THE PURSUIT OF GOALS

22.2 INTENT AND APPLICABILITY

22.3 INTRODUCTION TO THE STRATEGY PATTERN

22.4 THE STRATEGY PATTERN IN REAL-WORLD APPLICATIONS

22.5 HARRY POTTER STORY USED TO ILLUSTRATE THE STRATEGY PATTERN

22.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

22.7 THE ABSTRACT ROOT CLASS FOR STRATEGIES: StrategyAbstractRoot

22.8 THE CONCRETE STRATEGY CLASSES

22.9 THE Champion CLASS

22.10 THE SecondTaskManager CLASS

22.11 PLAYING WITH THE CODE

23 TEMPLATE METHOD

23.1 CUSTOMIZABLE RECIPES

23.2 INTENT AND APPLICABILITY

23.3 INTRODUCTION TO THE TEMPLATE METHOD PATTERN

23.4 THE TEMPLATE METHOD PATTERN IN REAL-WORLD APPLICATIONS

23.5 HARRY POTTER STORY USED TO ILLUSTRATE THE TEMPLATE METHOD PATTERN

23.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

23.7 THE ABSTRACT ROOT OF NARRATIVE GENERATION CLASSES

23.8 CONCRETE CLASSES FOR NARRATIVE GENERATION

23.9 THE EXECUTABLE CLASS

23.10 PLAYING WITH THE CODE

24 VISITOR

24.1 HOOKS, GOOD AND EVIL

24.2 INTENT AND APPLICABILITY

24.3 INTRODUCTION TO THE VISITOR PATTERN

24.4 THE VISITOR PATTERN IN REAL-WORLD APPLICATIONS

24.5 HARRY POTTER STORY USED TO ILLUSTRATE THE VISITOR PATTERN

24.6 A TOP LEVEL VIEW OF THE PATTERN DEMONSTRATION

24.7 THE Visitor INTERFACE

24.8 TWO CONCRETE IMPLEMENTATIONS OF THE Visitor INTERFACE

24.9 A RE-IMPLEMENTATION OF THE Wizard HIERARCHY OF THE COMPOSITE PATTERN

24.10 THE EXECUTABLE CLASS Client

24.11 PLAYING WITH THE CODE

REFERENCES

INDEX

End User License Agreement

List of Illustrations

Chapter 01

Fig. 1.1

Fig. 1.2

Fig. 1.3

Fig. 1.4

Fig. 1.5

Fig. 1.6

Fig. 1.7

Fig. 1.8

Chapter 02

Fig. 2.1

Fig. 2.2

Fig. 2.3

Fig. 2.4

Chapter 03

Fig. 3.1

Fig. 3.2

Fig. 3.3

Chapter 04

Fig. 4.1

Fig. 4.2

Fig. 4.3

Fig. 4.4

Chapter 05

Fig. 5.1

Fig. 5.2

Chapter 06

Fig. 6.1

Chapter 07

Fig. 7.1

Fig. 7.2

Fig. 7.3

Fig. 7.4

Chapter 08

Fig. 8.1

Fig. 8.2

Fig. 8.3

Fig. 8.4

Fig. 8.5

Fig. 8.6

Fig. 8.7

Chapter 09

Fig. 9.1

Fig. 9.2

Fig. 9.3

Fig. 9.4

Fig. 9.5

Chapter 10

Fig. 10.1

Fig. 10.2

Fig. 10.3

Fig. 10.4

Fig. 10.5

Fig. 10.6

Fig. 10.7

Chapter 11

Fig. 11.1

Fig. 11.2

Fig. 11.3

Fig. 11.4

Chapter 12

Fig. 12.1

Fig. 12.2

Chapter 13

Fig. 13.1

Fig. 13.2

Chapter 14

Fig. 14.1

Fig. 14.2

Fig. 14.3

Chapter 15

Fig. 15.1

Fig. 15.2

Fig. 15.3

Chapter 16

Fig. 16.1

Chapter 17

Fig. 17.1

Chapter 18

Fig. 18.1

Fig. 18.2

Chapter 19

Fig. 19.1

Fig. 19.2

Chapter 20

Fig. 20.1

Fig. 20.2

Chapter 21

Fig. 21.1

Chapter 22

Fig. 22.1

Fig. 22.2

Chapter 23

Fig. 23.1

Fig. 23.2

Chapter 24

Fig. 24.1

Fig. 24.2

Fig. 24.3

Fig. 24.4

Guide

Cover

Table of Contents

Begin Reading

Pages

iii

iv

xiv

xv

xvi

xvii

xix

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

249

250

251

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

422

423

424

425

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

DESIGNING WITH OBJECTS

Object-Oriented Design Patterns Explained with Stories from Harry Potter

AVINASH C. KAK

Purdue University

Cover Image: Courtesy from the author

Copyright © 2015 by John Wiley & Sons, Inc. All rights reserved

Published by John Wiley & Sons, Inc., Hoboken, New JerseyPublished simultaneously in Canada

No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4470, or on the web at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permission.

Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.

For general information on our other products and services or for technical support, please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.

Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic formats. For more information about Wiley products, visit our web site at www.wiley.com.

Library of Congress Cataloging-in-Publication Data:

Kak, Avinash C. Designing with objects : object-oriented design patterns explained with stories from Harry Potter / Avinash C. Kak.  pages cm Includes index.

 ISBN 978-1-118-58120-9 (paperback)1. Object-oriented programming (Computer science)  2. Rowling, J. K.–Themes, motives.  3. Rowling, J. K.–Characters.  4. Potter, Harry (Fictitious character) I. Title.

  QA76.64.K3548 2014  005.1′ 17–dc23

      2014007132

PREFACE

Readers who have been following the progress of my Objects Trilogy project will be pleased to see this third and final book of the Trilogy — even if it is almost two years behind schedule.

As to the cause for the delay, the primary culprit was finding the right medium for explaining the design patterns. When I first announced my Objects Trilogy project several years back, my plan, as stated then, was to explain the patterns through famous short stories of the world. By famous I meant classic and universal — the sort that would not need to be re-told when used for explaining the patterns. These would be the stories by Hans Christian Anderson, the Brothers Grimm, and their counterparts from around the world. But, unfortunately, when I started mapping the patterns onto the stories, it became increasingly clear that such stories did not possess the level of complexity that was needed for the patterns. That’s when I turned to Harry Potter.

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!