Sarcar | Java Design Patterns | E-Book | www2.sack.de
E-Book

E-Book, Englisch, 512 Seiten

Sarcar Java Design Patterns

A Hands-On Experience with Real-World Examples
2. ed
ISBN: 978-1-4842-4078-6
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark

A Hands-On Experience with Real-World Examples

E-Book, Englisch, 512 Seiten

ISBN: 978-1-4842-4078-6
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark



Get hands-on experience implementing 26 of the most common design patterns using Java and Eclipse. In addition to Gang of Four (GoF) design patterns, you will also learn about alternative design patterns, and understand the criticisms of design patterns with an overview of anti-patterns. For each pattern you will see at least one real-world scenario, a computer-world example, and a complete implementation including output.This book has three parts. The first part covers 23 Gang of Four (GoF) design patterns. The second part includes three alternative design patterns. The third part presents criticisms of design patterns with an overview of anti-patterns. You will work through easy-to-follow examples to understand the concepts in depth and you will have a collection of programs to port over to your own projects.A Q&A session is included in each chapter and covers the pros and cons of each pattern. The last chapter presents FAQs about the design patterns. The step-by-step approach of the book helps you apply your skills to learn other patterns on your own, and to be familiar with the latest version of Java and Eclipse.

What You'll Learn 
Work with each of the design patterns
Implement design patterns in real-world applications
Choose from alternative design patterns by comparing their pros and cons
Use the Eclipse IDE to write code and generate output
Read the in-depth Q&A session in each chapter with pros and cons for each design pattern

Who This Book Is For 
Software developers, architects, and programmers

Vaskaran Sarcar obtained his Master of Engineering degree from Jadavpur University, Kolkata, in Software Engineering. Currently, he is Senior Software Engineer and Team Lead in the R&D Hub at HP Inc. India. He was a national Gate Scholar and has more than 12 years of experience in education and the IT industry. He is an alumnus of prestigious institutions in India such as Jadavpur University, Vidyasagar University, and Presidency University (formerly Presidency College). Reading and learning new things are his passions. You can connect to Vaskaran on LinkedIn.
Other books by Vaskaran include the following: Design Patterns in C# (Apress), Interactive C# (Apress), Interactive Object-Oriented Programming in Java (Apress), Java Design Patterns (First Edition) (Apress), C# Basics: Test Your Skill, and Operating System: Computer Science Interview Series.

Sarcar Java Design Patterns jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


1;Table of Contents;5
2;About the Author;19
3;About the Technical Reviewers;20
4;Acknowledgments;22
5;Foreword;23
6;Introduction;24
7;Part I: Gang of Four Patterns;31
7.1;Chapter 1: Singleton Pattern;32
7.1.1;GoF Definition;32
7.1.2;Concept;32
7.1.3;Real-World Example;32
7.1.4;Computer-World Example;33
7.1.5;Illustration;33
7.1.5.1;Class Diagram;33
7.1.5.2;Package Explorer View;34
7.1.5.3;Discussion;34
7.1.5.4;Implementation;35
7.1.5.5;Output;36
7.1.6;Q&A Session;36
7.1.6.1;Output;40
7.1.6.2;Eager Initialization;41
7.1.6.2.1;Discussion;41
7.1.6.2.2;Output;43
7.1.6.2.3;Analysis;43
7.1.6.3;Bill Pugh’s Solution;43
7.1.6.4;Double-Checked Locking;44
7.2;Chapter 2: Prototype Pattern;47
7.2.1;GoF Definition;47
7.2.2;Concept;47
7.2.3;Real-World Example;47
7.2.4;Computer-World Example;48
7.2.5;Illustration;48
7.2.5.1;Class Diagram;48
7.2.5.2;Package Explorer View;50
7.2.5.3;Implementation;51
7.2.5.4;Output;53
7.2.6;Q&A Session;54
7.2.6.1;Demonstration;57
7.2.6.2;Output;59
7.3;Chapter 3: Builder Pattern;60
7.3.1;GoF Definition;60
7.3.2;Concept;60
7.3.3;Real-World Example;61
7.3.4;Computer-World Example;61
7.3.5;Illustration;62
7.3.5.1;Class Diagram;63
7.3.5.2;Package Explorer View;63
7.3.5.3;Implementation;65
7.3.5.4;Output;69
7.3.6;Q&A Session;69
7.3.6.1;Modified Illustration;73
7.3.6.2;Modified Package Explorer View;73
7.3.6.3;Modified Implementation;75
7.3.6.4;Modified Output;79
7.3.6.5;Analysis;80
7.4;Chapter 4: Factory Method Pattern;82
7.4.1;GoF Definition;82
7.4.2;Concept;82
7.4.3;Real-World Example;83
7.4.4;Computer-World Example;83
7.4.5;Illustration;84
7.4.5.1;Class Diagram;84
7.4.5.2;Package Explorer View;85
7.4.5.3;Implementation;85
7.4.5.4;Output;88
7.4.5.5;Modified Implementation;88
7.4.5.6;Modified Output;90
7.4.5.7;Analysis;90
7.4.6;Q&A Session;90
7.5;Chapter 5: Abstract Factory Pattern;94
7.5.1;GoF Definition;94
7.5.2;Concept;94
7.5.3;Real-World Example;95
7.5.4;Computer-World Example;95
7.5.5;Illustration;95
7.5.5.1;Class Diagram;97
7.5.5.2;Package Explorer View;98
7.5.5.3;Implementation;99
7.5.5.4;Output;103
7.5.6;Q&A Session;103
7.5.6.1;Simple Factory Pattern Code Snippet;104
7.5.6.2;Factory Method Pattern Code Snippet;105
7.5.6.3;Abstract Factory Pattern Code Snippet;105
7.5.6.4;Conclusion;106
7.5.6.5;Modified Illustration;107
7.5.6.6;Modified Implementation;107
7.5.6.7;Modified Output;112
7.6;Chapter 6: Proxy Pattern;113
7.6.1;GoF Definition;113
7.6.2;Concept;113
7.6.3;Real-World Example;113
7.6.4;Computer-World Example;114
7.6.5;Illustration;114
7.6.5.1;Class Diagram;114
7.6.5.2;Package Explorer View;115
7.6.5.3;Implementation;116
7.6.5.4;Output;118
7.6.6;Q&A Session;118
7.6.6.1;Alternate Implementation;119
7.6.6.2;Output Without Lazy Instantiation;121
7.6.6.3;Analysis;122
7.6.6.4;Output with Lazy Instantiation;122
7.6.6.5;Analysis;122
7.6.6.6;Modified Package Explorer View;124
7.6.6.7;Modified Implementation;125
7.6.6.8;Modified Output;127
7.7;Chapter 7: Decorator Pattern;129
7.7.1;GoF Definition;129
7.7.2;Concept;129
7.7.3;Real-World Example;129
7.7.4;Computer-World Example;131
7.7.5;Illustration;132
7.7.5.1;Class Diagram;132
7.7.5.2;Package Explorer View;133
7.7.5.3;Implementation;133
7.7.5.4;Output;136
7.7.6;Q&A Session;137
7.8;Chapter 8: Adapter Pattern;143
7.8.1;GoF Definition;143
7.8.2;Concept;143
7.8.3;Real-World Example;143
7.8.4;Computer-World Example;144
7.8.5;Illustration;145
7.8.5.1;Class Diagram;146
7.8.5.2;Package Explorer View;146
7.8.5.3;Implementation;147
7.8.5.4;Output;149
7.8.5.5;Modified Illustration;149
7.8.5.6;Modified Class Diagram;149
7.8.5.7;Key Characteristics of the Modified Implementation;150
7.8.5.8;Modified Package Explorer View;152
7.8.5.9;Modified Implementation;153
7.8.5.10;Modified Output;156
7.8.5.11;Types of Adapters;156
7.8.5.11.1;Object Adapters;156
7.8.5.11.2;Class Adapters;157
7.8.6;Q&A Session;158
7.9;Chapter 9: Facade Pattern;161
7.9.1;GoF Definition;161
7.9.2;Concept;161
7.9.3;Real-World Example;161
7.9.4;Computer-World Example;162
7.9.5;Illustration;162
7.9.5.1;Class Diagram;163
7.9.5.2;Package Explorer View;164
7.9.5.3;Implementation;165
7.9.5.4;Output;169
7.9.6;Q&A Session;170
7.10;Chapter 10: Flyweight Pattern;173
7.10.1;GoF Definition;173
7.10.2;Concept;173
7.10.3;Real-World Example;174
7.10.4;Computer-World Example;174
7.10.5;Illustration;175
7.10.5.1;Class Diagram;176
7.10.5.2;Package Explorer View;176
7.10.5.3;Implementation;177
7.10.5.4;Output;183
7.10.5.5;Analysis;185
7.10.6;Q&A Session;185
7.11;Chapter 11: Composite Pattern;190
7.11.1;GoF Definition;190
7.11.2;Concept;190
7.11.3;Real-World Example;191
7.11.4;Computer-World Example;191
7.11.5;Illustration;191
7.11.5.1;Class Diagram;192
7.11.5.2;Package Explorer View;193
7.11.5.3;Implementation;194
7.11.5.4;Output;199
7.11.6;Q&A Session;201
7.12;Chapter 12: Bridge Pattern;204
7.12.1;GoF Definition;204
7.12.2;Concept;204
7.12.3;Real-World Example;204
7.12.4;Computer-World Example;205
7.12.5;Illustration;205
7.12.5.1;Class Diagram;208
7.12.5.2;Package Explorer View;209
7.12.5.3;Key Characteristics;210
7.12.5.4;Implementation;210
7.12.5.5;Output;214
7.12.6;Q&A Session;215
7.13;Chapter 13: Visitor Pattern;217
7.13.1;GoF Definition;217
7.13.2;Concept;217
7.13.3;Real-World Example;218
7.13.4;Computer-World Example;218
7.13.5;Illustration;218
7.13.5.1;Class Diagram;219
7.13.5.2;Package Explorer View;220
7.13.5.3;Implementation;220
7.13.5.4;Output;222
7.13.5.5;Modified Illustration;222
7.13.5.5.1;Key Characteristic of the Modified Example;223
7.13.5.5.2;Step 1;224
7.13.5.5.3;Step 2;224
7.13.5.5.4;Step 3;225
7.13.5.5.5;Step 4;226
7.13.5.5.6;Step 5;226
7.13.5.6;Modified Class Diagram;228
7.13.5.7;Modified Package Explorer View;228
7.13.5.8;Modified Implementation;230
7.13.5.9;Modified Output;236
7.13.6;Q&A Session;237
7.14;Chapter 14: Observer Pattern;240
7.14.1;GoF Definition;240
7.14.2;Concept;240
7.14.3;Real-World Example;243
7.14.4;Computer-World Example;243
7.14.5;Illustration;244
7.14.5.1;Class Diagram;245
7.14.5.2;Package Explorer View;245
7.14.5.3;Implementation;247
7.14.5.4;Output;250
7.14.5.5;Analysis;250
7.14.6;Q&A Session;250
7.15;Chapter 15: Strategy (Policy) Pattern;255
7.15.1;GoF Definition;255
7.15.2;Concept;255
7.15.3;Real-World Example;255
7.15.4;Computer world Example;256
7.15.5;Illustration;256
7.15.5.1;Class Diagram;257
7.15.5.2;Package Explorer View;257
7.15.5.3;Implementation;259
7.15.5.4;Output;262
7.15.6;Q&A Session;262
7.16;Chapter 16: Template Method Pattern;272
7.16.1;GoF Definition;272
7.16.2;Concept;272
7.16.3;Real-World Example;272
7.16.4;Computer-World Example;273
7.16.5;Illustration;273
7.16.5.1;Class Diagram;273
7.16.5.2;Package Explorer View;274
7.16.5.3;Implementation;275
7.16.5.4;Output;277
7.16.6;Q&A Session;277
7.16.6.1;Modified Implementation;278
7.16.6.2;Modified Output;281
7.17;Chapter 17: Command Pattern;283
7.17.1;GoF Definition;283
7.17.2;Concept;283
7.17.3;Real-World Example;283
7.17.4;Computer-World Example;284
7.17.5;Illustration;284
7.17.5.1;Class Diagram;285
7.17.5.2;Package Explorer View;286
7.17.5.3;Implementation;287
7.17.5.4;Output;290
7.17.6;Q&A Session;290
7.17.6.1;Modified Class Diagram;291
7.17.6.2;Modified Package Explorer View;292
7.17.6.3;Modified Implementation;294
7.17.6.4;Modified Output;300
7.18;Chapter 18: Iterator Pattern;304
7.18.1;GoF Definition;304
7.18.2;Concept;304
7.18.3;Real-World Example;305
7.18.4;Computer-World Example;306
7.18.5;Illustration;306
7.18.5.1;Class Diagram;307
7.18.5.2;Package Explorer View;309
7.18.5.3;First Implementation;310
7.18.5.4;Output;312
7.18.5.5;Key Characteristics of the Second Implementation;313
7.18.5.6;Second Implementation;313
7.18.5.7;Output;315
7.18.6;Q&A Session;316
7.18.6.1;Third Implementation;318
7.18.6.2;Output;321
7.19;Chapter 19: Memento Pattern;322
7.19.1;GoF Definition;322
7.19.2;Concept;322
7.19.3;Real-World Example;322
7.19.4;Computer-World Example;323
7.19.5;Illustration;323
7.19.5.1;Class Diagram;324
7.19.5.2;Package Explorer View;325
7.19.5.3;Implementation;325
7.19.5.4;Output;328
7.19.6;Q&A Session;329
7.19.6.1;Modified Caretaker Class;330
7.19.6.2;Modified Output;331
7.19.6.3;Analysis;332
7.19.6.4;Shallow Copy vs. Deep Copy in Java;340
7.19.6.4.1;Key Characteristics of the Following Program;340
7.19.6.4.2;Implementation;341
7.19.6.4.3;Output;344
7.19.6.4.4;Analysis;344
7.19.6.4.5;Modified Output;345
7.19.6.4.6;Analysis;345
7.20;Chapter 20: State Pattern;347
7.20.1;GoF Definition;347
7.20.2;Concept;347
7.20.3;Real-World Example;348
7.20.4;Computer-World Example;348
7.20.5;Illustration;348
7.20.5.1;Key Characteristics;350
7.20.5.2;Class Diagram;350
7.20.5.3;Package Explorer View;352
7.20.5.4;Implementation;353
7.20.5.5;Output;357
7.20.6;Q&A Session;358
7.20.6.1;Modified Package Explorer View;361
7.20.6.2;Modified Implementation;363
7.20.6.3;Modified Output;368
7.21;Chapter 21: Mediator Pattern;371
7.21.1;GoF Definition;371
7.21.2;Concept;371
7.21.3;Real-World Example;371
7.21.4;Computer-World Example;372
7.21.5;Illustration;373
7.21.5.1;Class Diagram;374
7.21.5.2;Package Explorer View;375
7.21.5.3;Implementation;377
7.21.5.4;Output;381
7.21.5.5;Analysis;381
7.21.5.6;Modified Illustration;381
7.21.5.7;Modified Class Diagram;383
7.21.5.8;Modified Package Explorer View;384
7.21.5.9;Modified Implementation;385
7.21.5.10;Modified Output;390
7.21.5.11;Analysis;391
7.21.6;Q&A Session;391
7.22;Chapter 22: Chain-of-Responsibility Pattern;395
7.22.1;GoF Definition;395
7.22.2;Concept;395
7.22.3;Real-World Example;396
7.22.4;Computer-World Example;396
7.22.5;Illustration;397
7.22.5.1;Class Diagram;398
7.22.5.2;Package Explorer View;399
7.22.5.3;Implementation;400
7.22.5.4;Output;403
7.22.6;Q&A Session;404
7.23;Chapter 23: Interpreter Pattern;406
7.23.1;GoF Definition;406
7.23.2;Concept;406
7.23.3;Real-World Example;408
7.23.4;Computer-World Example;408
7.23.5;Illustration;408
7.23.5.1;Class Diagram;410
7.23.5.2;Package Explorer View;411
7.23.5.3;Implementation;412
7.23.5.4;Output;416
7.23.5.5;Analysis;417
7.23.5.6;Modified Illustration;417
7.23.5.7;Modified Class Diagram;417
7.23.5.8;Modified Package Explorer View;417
7.23.5.9;Modified Implementation;418
7.23.5.10;Modified Output;423
7.23.5.11;Analysis;423
7.23.6;Q&A Session;424
8;Part II: Additional Design Patterns;425
8.1;Chapter 24: Simple Factory Pattern;426
8.1.1;Intent;426
8.1.2;Concept;426
8.1.3;Real-World Example;426
8.1.4;Computer-World example;427
8.1.5;Illustration;428
8.1.5.1;Class Diagram;428
8.1.5.2;Package Explorer View;429
8.1.5.3;Implementation;430
8.1.5.4;Output;432
8.1.5.4.1;Case1. User input:0;433
8.1.5.4.2;Case2. User input:1;433
8.1.5.4.3;Case3. An unwanted user input:2;433
8.1.6;Q&A Session;434
8.2;Chapter 25: Null Object Pattern;436
8.2.1;Concept;436
8.2.1.1;A Faulty Program;437
8.2.1.2;Output with Valid Inputs;439
8.2.1.3;Analysis with an Unwanted Input;439
8.2.1.4;Encountered Exception;440
8.2.1.5;Immediate Remedy;440
8.2.1.6;Analysis;440
8.2.2;Real-World Example;441
8.2.3;Computer-World Example;441
8.2.4;Illustration;441
8.2.4.1;Class Diagram;442
8.2.4.2;Package Explorer View;443
8.2.4.3;Implementation;444
8.2.4.4;Output;447
8.2.4.5;Analysis;448
8.2.5;Q&A Session;448
8.3;Chapter 26: MVC Pattern;452
8.3.1;Concept;452
8.3.1.1;Key Points to Remember;453
8.3.1.2;Variation 1;454
8.3.1.3;Variation 2;454
8.3.1.4;Variation 3;455
8.3.2;Real-World Example;455
8.3.3;Computer-World Example;456
8.3.4;Illustration;457
8.3.4.1;Class Diagram;457
8.3.4.2;Package Explorer View;459
8.3.4.3;Implementation;459
8.3.4.4;Output;467
8.3.5;Q&A Session;468
8.3.5.1;Modified Output;470
9;Part III: Final Discussions on Design Patterns;473
9.1;Chapter 27: Criticisms of Design Patterns;474
9.1.1;Q&A Session;476
9.2;Chapter 28: AntiPatterns: Avoid the Common Mistakes;480
9.2.1;What Is an Antipattern?;480
9.2.2;Brief History of Antipatterns;481
9.2.3;Examples of Antipatterns;482
9.2.4;Types of Antipatterns;484
9.2.5;Q&A Session;484
9.3;Chapter 29: FAQs;488
10;Appendix A: A Brief Overview of GoF Design Patterns;494
10.1;Key Points;495
10.2;A. Creational Patterns;496
10.3;B. Structural Patterns;496
10.4;C. Behavioral Patterns;497
10.4.1;Q&A Session;499
11;Appendix B: Winning Notes and the Road Ahead;502
12;Appendix C: Bibliography;503
13;Index;505



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.