Part I Principles
1 Architects and Architecture Today 3
What's a Software Architecture, Anyway? 4
Applying Architectural Principles to Software 4
What's Architecture and What's Not 8
Architecture Is About Decisions 10
Requirements and Quality of Software 12
Who's the Architect, Anyway? 17
An Architect's Responsibilities 17
How Many Types of Architects Do You Know? 20
Common Misconceptions About Architects 21
Overview of the Software Development Process 24
The Software Life Cycle 24
Models for Software Development 26
Summary 30
Murphy's Laws of the Chapter 30
2 UML Essentials 31
UML at a Glance 32
Motivation for and History of Modeling Languages 33
UML Modes and Usage 36
UML Diagrams 41
Use-Case Diagrams 43
Class Diagrams 47
Sequence Diagrams 53
Summary 61
Murphy's Laws of the Chapter 61
3 Design Principles and Patterns 63
Basic Design Principles 63
For What the Alarm Bell Should Ring 65
Structured Design 66
Separation of Concerns 70
Object-Oriented Design 73
Basic OOD Principles 73
Advanced Principles 80
From Principles to Patterns 85
What's a Pattern, Anyway? 86
Patterns vs. Idioms 92
Dependency Injection 95
Applying Requirements by Design 97
Testability 97
Security 108
From Objects to Aspects 116
Aspect-Oriented Programming 11
AOP in Action 120
Summary 124
Murphy's Laws of the Chapter 125
Part II Design of the System
4 The Business Layer 129
What's the Business Logic Layer, Anyway? 130
Dissecting the Business Layer 130
Where Would You Fit the BLL? 134
Business and Other Layers 138
Patterns for Creating the Business Layer 141
The Transaction Script Pattern 145
Generalities of the TS Pattern 145
The Pattern in Action 149
The Table Module Pattern 154
Generalities of the TM Pattern 155
The TM Pattern in Action 159
The Active Record Pattern 165
Generalities of the AR Pattern 166
The AR Pattern in Action 168
The Domain Model Pattern 176
Generalities of the DM Pattern 177
The DM Pattern in Action 181
Summary 191
Murphy's Laws of the Chapter 192
5 The Service Layer 193
What's the Service Layer, Anyway? 194
Responsibilities of the Service Layer 195
What's a Service, Anyway? 198
Services in the Service Layer 201
The Service Layer Pattern in Action 205
Generalities of the Service Layer Pattern 205
The Service Layer Pattern in Action 208
Related Patterns 213
The Remote Fa?ade Pattern 213
The Data Transfer Object Pattern 216
The Adapter Pattern 218
DTO vs. Assembly 221
Service-Oriented Architecture 229
Tenets of SOA 230
What SOA Is Not 232
SOA and the Service Layer 234
The Very Special Case of Rich Web Front Ends 237
Refactoring the Service Layer 238
Designing an AJAX Service Layer 242
Securing the AJAX Service Layer 246
Summary 250
Murphy's Laws of the Chapter 250
6 The Data Access Layer 251
What's the Data Access Layer, Anyway? 251
Functional Requirements of the Data Access Layer 252
Responsibilities of the Data Access Layer 254
The Data Access Layer and Other Layers 260
Designing Your Own Data Access Layer 263
The Contract of the DAL 263
The Plugin Pattern 267
The Inversion of Control Pattern 273
Laying the Groundwork for a Data Context 277
Crafting Your Own Data Access Layer 280
Implementing the Persistence Layer 281
Implementing Query Services 289
Implementing Transactional Semantics 298
Implementing Uniquing and Identity Maps 305
Implementing Concurrency 311
Implementing Lazy Loading 315
Power to the DAL with an O/RM Tool 321
Object/Relational Mappers 322
Using an O/RM Tool to Build a DAL 325
To SP or Not to SP 333
About Myths and Stored Procedures 333
What About Dynamic SQL? 339
Summary 340
Murphy's Laws of the Chapter 341
7 The Presentation Layer 343
User Interface and Presentation Logic 344
Responsibilities of the Presentation Layer 345
Responsibilities of the User Interface 348
Common Pitfalls of a Presentation Layer 350
Evolution of the Presentation Patterns 352
The Model-View-Controller Pattern 353
The Model-View-Presenter Pattern 364
The Presentation Model Pattern 370
Choosing a Pattern for the User Interface 372
Design of the Presentation 375
What Data Is Displayed in the View? 375
Processing User Actions 381
Idiomatic Presentation Design 390
MVP in Web Presentations 390
MVP in Windows Presentations 395
Summary 398
Murphy's Laws of the Chapter 399
Final Thoughts 401
Appendix: The Northwind Starter Kit 405
Index 413