Java Program Design (eBook)
XVII, 456 Seiten
Apress (Verlag)
978-1-4842-4143-1 (ISBN)
- Create well-designed programs, and identify and improve poorly-designed ones
- Build a professional-level understanding of polymorphism and its use in Java interfaces and class hierarchies
- Apply classic design patterns to Java programming problems while respecting the modern features of the Java language
- Take advantage of classes from the Java library to facilitate the implementation of design patterns in your programs
?Edward Sciore is Associate Professor in the computer science department at Boston College. He has been teaching college students for over 30 years. His research specialty is database systems, and he thoroughly enjoys teaching the wonders of database technology to captive students. Edward is author of Understanding Oracle APEX 5 Application Development (Apress).
Get a grounding in polymorphism and other fundamental aspects of object-oriented program design and implementation, and learn a subset of design patterns that any practicing Java professional simply must know in today's job climate. Java Program Design presents program design principles to help practicing programmers up their game and remain relevant in the face of changing trends and an evolving language. The book enhances the traditional design patterns with Java's new functional programming features, such as functional interfaces and lambda expressions. The result is a fresh treatment of design patterns that expands their power and applicability, and reflects current best practice. The book examines some well-designed classes from the Java class library, using them to illustrate the various object-oriented principles and patterns under discussion. Not only does this approach provide good, practical examples, but you will learn useful library classes you might not otherwise know about.The design of a simplified banking program is introduced in chapter 1 in a non-object-oriented incarnation and the example is carried through all chapters. You can see the object orientation develop as various design principles are progressively applied throughout the book to produce a refined, fully object-oriented version of the program in the final chapter. What You'll LearnCreate well-designed programs, and identify and improve poorly-designed onesBuild a professional-level understanding of polymorphism and its use in Java interfaces and class hierarchiesApply classic design patterns to Java programming problems while respecting the modern features of the Java languageTake advantage of classes from the Java library to facilitatethe implementation of design patterns in your programsWho This Book Is ForJava programmers who are comfortable writing non-object-oriented code and want a guided immersion into the world of object-oriented Java, and intermediate programmers interested in strengthening their foundational knowledge and taking their object-oriented skills to the next level. Even advanced programmers will discover interesting examples and insights in each chapter.
Edward Sciore is a recently retired Associate Professor at Boston College, who gleefully taught computer science to college students for over 35 years. This book is the result of his experiences teaching courses on Java programming, object-oriented design, and software engineering. Edward is author of Understanding Oracle APEX 5 Application Development (Apress, 2015) and Database Design and Implementation (Wiley, 2008).
Table of Contents 4
About the Author 10
About the Technical Reviewer 11
Acknowledgments 12
Introduction 13
Chapter 1: Modular Software Design 16
Designing for Change 16
Object-Oriented Basics 19
APIs and Dependencies 19
Modularity 20
Class Diagrams 21
Static vs. Nonstatic 23
A Banking Demo 24
The Single Responsibility Rule 28
Refactoring 34
Unit Testing 35
Class Design 38
Encapsulation 44
Redistributing Responsibility 46
Dependency Injection 51
Mediation 55
Design Tradeoffs 56
The Design of Java Maps 58
Summary 60
Chapter 2: Polymorphism 62
The Need for Polymorphism 62
Interfaces 65
Reference Types 69
Type Safety 73
Type Casting 74
Transparency 76
The Open-Closed Rule 78
The Comparable Interface 79
Subtypes 82
The Java Collection Library 85
ArrayList 88
LinkedList 88
HashSet 88
TreeSet 88
The Liskov Substitution Principle 88
Should SortedSet Extend List? 90
Why Isn’t There an Interface SortedList? 90
Should Queue Extend List? Should List Extend Queue? 91
Why Have the Interface Set if It Doesn’t Provide any Added Functionality? 91
The Rule of Abstraction 92
Adding Code to an Interface 95
Summary 99
Chapter 3: Class Hierarchies 101
Subclasses 101
Abstract Classes 107
Writing Java Collection Classes 117
Byte Streams 119
The Template Pattern 132
Summary 140
Chapter 4: Strategies 141
The Strategy Pattern 141
Comparators 150
Anonymous Inner Classes 154
Explicit Anonymous Classes 154
Lambda Expressions 155
The Strategy Pattern as a Design Tool 158
The Command Pattern 164
Eliminating the Class Hierarchy 170
Templates vs. Strategies 174
Summary 176
Chapter 5: Encapsulating Object Creation 177
Object Caching 177
Singleton Classes 183
Singleton Strategy Classes 186
Static Factory Methods 194
Factory Objects 199
Cached Factory Objects 202
The Factory Pattern 206
Factories for Customized Objects 209
Summary 212
Chapter 6: Iterables and Iteration 214
Iterators 214
Writing an Iterator Class 218
The Iterator Pattern 223
Designing Iterable Classes 225
External Iteration 227
Internal Iteration 230
The Visitor Pattern 232
Predicates 236
Collection Streams 240
Summary 246
Chapter 7: Adapters 249
Inheritance for Reuse 249
Wrappers 251
The Adapter Pattern 252
Text Streams 256
The Adapter OutputStreamWriter 258
The Adapter InputStreamReader 262
The Adapter StringReader 266
Object Streams 267
Saving State in the Banking Demo 272
Adapters for the Banking Demo 275
Summary 281
Chapter 8: Decorators 283
Decorator Classes 283
The Decorator Pattern 289
The Chain of Command Pattern 295
Decorated Iterators 300
Implementing Collection Streams 306
Decorated Input Streams 310
Buffered Input Streams 311
Progress Monitoring 314
Cipher Input Streams 316
Decorator Transparency 318
Summary 324
Chapter 9: Composites 326
Predicates as Composites 326
Composite Objects in JavaFX 334
The Composite Pattern 344
A Cookbook Example 347
Traversing a Composite Object 352
Summary 361
Chapter 10: Observers 363
Observers and Observables 363
The Observer Pattern 368
Push vs. pull 369
Managing the Observer List 371
The Generic Observer Pattern in Java 375
Events 379
Observers in JavaFX 384
JavaFX Properties 389
Properties as Wrappers 389
Properties as Observables 391
JavaFX Bindings 394
Summary 398
Chapter 11: Model, View, and Controller 399
The MVC Design Rule 400
Multiple Views for a Model 407
MVC in Excel 413
JavaFX Views and Controllers 415
Extending the MVC Architecture 421
The MVC Pattern 427
MVC and the Banking Demo 432
The Class FxBankProgram 434
The Create Account View 436
The Account Information View 438
The All Accounts View 442
Observable List Views 445
Observable Table Views 448
Summary 451
Index 454
Erscheint lt. Verlag | 8.12.2018 |
---|---|
Zusatzinfo | XVII, 456 p. 70 illus. |
Verlagsort | Berkeley |
Sprache | englisch |
Themenwelt | Informatik ► Programmiersprachen / -werkzeuge ► Java |
Informatik ► Software Entwicklung ► Objektorientierung | |
Schlagworte | Class Design • Command pattern • Composite Pattern • Composition • constructors • Design Patterns • encapsulation • Inheritance • interfaces • Iterator pattern • Java 10 • Java 11 • java 9 • Model, View, Controller pattern • MVC architecture • Observer Pattern • Polymorphism • Rule of Abstraction • SDLC • solid |
ISBN-10 | 1-4842-4143-6 / 1484241436 |
ISBN-13 | 978-1-4842-4143-1 / 9781484241431 |
Haben Sie eine Frage zum Produkt? |
Größe: 6,1 MB
DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasserzeichen und ist damit für Sie personalisiert. Bei einer missbräuchlichen Weitergabe des eBooks an Dritte ist eine Rückverfolgung an die Quelle möglich.
Dateiformat: PDF (Portable Document Format)
Mit einem festen Seitenlayout eignet sich die PDF besonders für Fachbücher mit Spalten, Tabellen und Abbildungen. Eine PDF kann auf fast allen Geräten angezeigt werden, ist aber für kleine Displays (Smartphone, eReader) nur eingeschränkt geeignet.
Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.
Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.
Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.
aus dem Bereich