Design Patterns in Java, 2/e (Hardcover)

Steven John Metsker, William C. Wake

  • 出版商: Addison Wesley
  • 出版日期: 2006-03-01
  • 售價: $2,510
  • 貴賓價: 9.5$2,385
  • 語言: 英文
  • 頁數: 480
  • 裝訂: Hardcover
  • ISBN: 0321333020
  • ISBN-13: 9780321333025
  • 相關分類: Java 程式語言Design Pattern
  • 海外代購書籍(需單獨結帳)

買這商品的人也買了...

相關主題

商品描述

Description:

Coverage Includes

  • Using Adapter to provide consistent interfaces to clients
  • Using Facade to simplify the use of reusable toolkits
  • Understanding the role of Bridge in Java database connectivity
  • The Observer pattern, Model-View-Controller, and GUI behavior
  • Java Remote Method Invocation (RMI) and the Proxy pattern
  • Streamlining designs using the Chain of Responsibility pattern
  • Using patterns to go beyond Java's built-in constructor features
  • Implementing Undo capabilities with Memento
  • Using the State pattern to manage state more cleanly and simply
  • Optimizing existing codebases with extension patterns
  • Providing thread-safe iteration with the Iterator pattern
  • Using Visitor to define new operations without changing hierarchy classes

Design Patterns in Java™ gives you the hands-on practice and deep insight you need to fully leverage the significant power of design patterns in any Java software project. The perfect complement to the classic Design Patterns, this learn-by-doing workbook applies the latest Java features and best practices to all of the original 23 patterns identified in that groundbreaking text.

Drawing on their extensive experience as Java instructors and programmers, Steve Metsker and Bill Wake illuminate each pattern with real Java programs, clear UML diagrams, and compelling exercises. You'll move quickly from theory to application—learning how to improve new code and refactor existing code for simplicity, manageability, and performance.

If you're a Java programmer wanting to save time while writing better code, this book's techniques, tips, and clear explanations and examples will help you harness the power of patterns to improve every program you write, design, or maintain.

All source code is available for download at http://www.oozinoz.com.


 

Table of Contents:

Preface xiii Chapter 1 Introduction 1

Why Patterns? 1

Why Design Patterns? 2

Why Java? 3

UML 4

Challenges 4

The Organization of This Book 5

Welcome to Oozinoz! 6

Summary 7

Part I Interface Patterns 9Chapter 2 Introducing Interfaces 11

Interfaces and Abstract Classes 11

Interfaces and Obligations 13

Summary 15

Beyond Ordinary Interfaces 16

Chapter 3 Adapter 17

Adapting to an Interface 17

Class and Object Adapters 21

Adapting Data for a JTable 25

Identifying Adapters 30

Summary 31

Chapter 4 Facade 33

Facades, Utilities, and Demos 33

Refactoring to Facade 35

Summary 46

Chapter 5 Composite 47

An Ordinary Composite 47

Recursive Behavior in Composites 48

Composites, Trees, and Cycles 50

Composites with Cycles 56

Consequences of Cycles 60

Summary 60

Chapter 6 Bridge 63

An Ordinary Abstraction: On the Way to Bridge 63

From Abstraction to Bridge 66

Drivers as Bridges 68

Database Drivers 69

Summary 71

Part II Responsibility Patterns 73Chapter 7 Introducing Responsibility 75

Ordinary Responsibility 75

Controlling Responsibility with Visibility 77

Summary 79

Beyond Ordinary Responsibility 79

Chapter 8 Singleton 81

Singleton Mechanics 81

Singletons and Thread 83

Recognizing Singleton 84

Summary 86

Chapter 9 Observer 87

A Classic Example: Observer in GUIs 87

Model/View/Controller 92

Maintaining an Observable Object 99

Summary 101

Chapter 10 Mediator 103

A Classic Example: GUI Mediators 103

Mediators of Relational Integrity 108

Summary 116

Chapter 11 Proxy 117

A Classic Example: Image Proxies 117

Image Proxies Reconsidered 122

Remote Proxies 125

Dynamic Proxies 131

Summary 136

Chapter 12 Chain of Responsibility 137

An Ordinary Chain of Responsibility 137

Refactoring to Chain of Responsibility 139

Anchoring a Chain 142

Chain of Responsibility without Composite 144

Summary 144

Chapter 13 Flyweight 145

Immutability 145

Extracting the Immutable Part of a Flyweight 146

Sharing Flyweights 148

Summary 152

Part III Construction Patterns 153Chapter 14 Introducing Construction 155

A Few Construction Challenges 155

Summary 157

Beyond Ordinary Construction 157

Chapter 15 Builder 159

An Ordinary Builder 159

Building under Constraints 162

A Forgiving Builder 164

Summary 165

Chapter 16 Factory Method 167

A Classic Example: Iterators 167

Recognizing Factory Method 168

Taking Control of Which Class to Instantiate 169

Factory Method in Parallel Hierarchies 171

Summary 173

Chapter 17 Abstract Factory 175

A Classic Example: GUI Kits 175

Abstract Factories and Factory Method 180

Packages and Abstract Factories 184

Summary 185

Chapter 18 Prototype 187

Prototypes as Factories 187

Prototyping with Clones 189

Summary 192

Chapter 19 Memento 193

A Classic Example: Using Memento for Undo 193

Memento Durability 201

Persisting Mementos Across Sessions 201

Summary 205

Part IV Operation Patterns 207Chapter 20 Introducing Operations 209

Operations and Methods 209

Signatures 211

Exceptions 212

Algorithms and Polymorphism 213

Summary 214

Beyond Ordinary Operations 215

Chapter 21 Template Method 217

A Classic Example: Sorting 217

Completing an Algorithm 221

Template Method Hooks 224

Refactoring to Template Method 225

Summary 228

Chapter 22 State 229

Modeling States 229

Refactoring to State 233

Making States Constant 238

Summary 240

Chapter 23 Strategy 241

Modeling Strategies 241

Refactoring to Strategy 244

Comparing Strategy and State 248

Comparing Strategy and Template Method 249

Summary 250

Chapter 24 Command 251

A Classic Example: Menu Commands 251

Using Command to Supply a Service 254

Command Hooks 255

Command in Relation to Other Patterns 257

Summary 259

Chapter 25 Interpreter 261

An Interpreter Example 261

Interpreters, Languages, and Parsers 274

Summary 275

Part V Extension Patterns 277Chapter 26 Introducing Extensions 279

Principles of Object-Oriented Design 279

The Liskov Substitution Principle 280

The Law of Demeter 281

Removing Code Smells 283

Beyond Ordinary Extensions 283

Summary 285

Chapter 27 Decorator 287

A Classic Example: Streams and Writers 287

Function Wrappers 295

Decorator in Relation to Other Patterns 303

Summary 303

Chapter 28 Iterator 305

Ordinary Iteration 305

Thread-Safe Iteration 307

Iterating over a Composite 313

Summary 324

Chapter 29 Visitor 325

Visitor Mechanics 325

An Ordinary Visitor 327

Visitor Cycles 333

Visitor Risks 338

Summary 340

Part VI Appendixes 341Appendix A Directions 343

Get the Most from This Book 343

Understand the Classics 344

Weave Patterns into Your Code 344

Keep Learning 345

Appendix B Solutions 347Appendix C Oozinoz Source 427

Acquiring and Using the Source 427

Building the Oozinoz Code 427

Testing the Code with JUnit 428

Finding Files Yourself 428

Summary 429

Appendix D UML at a Glance 431

Classes 432

Class Relationships 433

Interfaces 435

Objects 436

States 437

Glossary 439Bibliography 447Index 449

商品描述(中文翻譯)

描述:
覆蓋範圍包括:
- 使用適配器為客戶端提供一致的接口
- 使用外觀模式簡化可重用工具包的使用
- 了解在Java數據庫連接中橋接器的角色
- 觀察者模式、模型-視圖-控制器和GUI行為
- Java遠程方法調用(RMI)和代理模式
- 使用職責鏈模式優化設計
- 使用模式超越Java內置的構造函數功能
- 使用備忘錄實現撤銷功能
- 使用狀態模式更清晰和簡單地管理狀態
- 使用擴展模式優化現有代碼庫
- 使用迭代器模式提供線程安全的迭代
- 使用訪問者模式在不更改層次結構類的情況下定義新操作

《Java設計模式》讓您在任何Java軟件項目中充分利用設計模式的重要力量,並提供實踐和深入洞察。作為經典《設計模式》的完美補充,這本以實踐為基礎的工作手冊應用了最新的Java功能和最佳實踐,涵蓋了原始23個模式。

作者Steve Metsker和Bill Wake憑藉他們作為Java教師和程序員的豐富經驗,用真實的Java程序、清晰的UML圖和引人入勝的練習解釋了每個模式。您將從理論迅速轉向應用,學習如何改進新代碼和重構現有代碼以實現簡潔、可管理和高性能。

如果您是一名Java程序員,想要在編寫更好的代碼時節省時間,本書的技巧、提示、清晰的解釋和示例將幫助您利用模式的力量改進您編寫、設計或維護的每個程序。

所有源代碼可在http://www.oozinoz.com上下載。

目錄:
- 前言
- 第1章:介紹
- 第2章:介面模式介紹