Domain-driven design (DDD) focuses on what matters in enterprise applications: the core business domain. Using object-oriented principles, you can develop a domain model that all team members-including business experts and technical specialists-can understand. Even better, this model is directly related to the underlying implementation. But if you've tried building a domain-driven application then you'll know that applying the DDD principles is easier said than done. Naked Objects, an open-source Java framework, lets you build working applications simply by writing the core domain classes. Naked Objects automatically renders your domain object in a generic viewer--either rich client or HTML. You can use its integration with Fitnesse to test-drive the development of your application, story-by-story. And once developed, you can deploy your application either to the full Naked Objects runtime, or within your existing application infrastructure. In this book, Dan Haywood first gives you the tools to represent your domain as plain old Java objects, expressing business rules both declaratively and imperatively. Next, you'll learn the techniques to deepen your design while keeping it maintainable as the scope of your application grows. Finally, you'll walk through the development practices needed to implement your domain applications, taking in testing, deployment, and extending Naked Objects itself. Throughout the book, you'll build a complete sample application, learning key DDD principles as you work through the application step by step. Every chapter ends with exercises to gain further experience in your own projects. Through its focus on the core business domain, DDD delivers value to your business stakeholders, and Naked Objects makes using DDD easy to accomplish. Using Naked Objects, you'll be ready in no time to build fully featured domain-driven applications. Cover......Page 1 Title......Page 5 Copyright......Page 6 Contents......Page 7 Preface......Page 14 Who This Book Is For......Page 15 How the Book Is Organized......Page 16 Case Study and Exercises......Page 17 Further Resources......Page 18 Tools......Page 20 Understanding Domain-Driven Design......Page 21 The Essentials of DDD......Page 22 Introducing Naked Objects......Page 26 Naked Objects in About Five Minutes......Page 28 How Naked Objects Helps with DDD......Page 34 The Big Picture......Page 37 Introducing CarServ......Page 41 Getting Ready......Page 43 Creating the Domain Classes......Page 45 Using Repositories to Locate Objects......Page 49 Identifying Objects to the User......Page 53 Capturing Simple Business Rules......Page 59 Providing Choices for Properties......Page 61 Associating Objects......Page 64 Adding Describing Concepts......Page 71 Capturing Business Rules for Collections......Page 77 Rapid Prototyping......Page 80 Fixtures for Setting Up Domain Objects......Page 81 Fixtures for Setting Up the Clock......Page 84 Fixtures for Setting Up User Sessions......Page 87 Organizing Fixtures into Hierarchies......Page 91 Creating Behaviorally Complete Objects......Page 95 Adding Behavior to Domain Objects......Page 96 Validating Action Arguments......Page 98 Making Actions Friendlier to Use......Page 101 Adding Finders to Repositories......Page 103 Implementing Business Rules......Page 106 Validation Recap......Page 107 Disabling Class Members......Page 110 Hiding Class Members......Page 113 Declarative Rules and the Object Life Cycle......Page 117 Validating the Entire Object......Page 120 Using Value Types......Page 124 Identifying Value Types......Page 125 Pushing Business Rules onto a Value Type......Page 126 Adding a Third-Party Value Type......Page 129 Specifying Defaults and Other Characteristics......Page 137 Isolating Infrastructure Services......Page 140 A Taxonomy of Services......Page 141 The Domain Object Container......Page 143 Dependency Injection......Page 145 Using Services in Fixtures......Page 146 Requirements for Writing Services......Page 147 Using Interfaces for Repositories......Page 149 Implementing a Calendar Service......Page 151 Hints and Tips for Writing Services......Page 154 Techniques......Page 157 Distributing Class Responsibilities......Page 158 Applying Coad Colors......Page 159 Factoring Out Objects......Page 161 Balancing Responsibilities......Page 166 Representing Large Collections with Finder......Page 168 Contributing Actions from Services......Page 172 Applying Domain Patterns......Page 176 Type as Factory Pattern......Page 177 Knowledge Level Pattern......Page 184 Null Object Pattern......Page 187 Role Object Pattern......Page 189 User Peer Object Pattern......Page 194 Strategy Pattern......Page 195 Process Object Pattern......Page 200 Keeping the Model Maintainable......Page 206 Analyzing the Structure of CarServ......Page 207 Decoupling by Moving Responsibilities......Page 210 Decoupling by Introducing Interfaces......Page 212 Layering Modules......Page 219 Decoupling by Splitting Classes......Page 221 Introducing an Application Package......Page 222 An Application Architecture Blueprint......Page 225 Scenario Testing......Page 229 Writing Developer Tests......Page 230 Scenario Testing Using FitNesse......Page 235 Getting Ready to Write Scenario Tests......Page 236 Writing Scenario Tests......Page 241 Hints and Tips......Page 249 Practices......Page 252 Developing Domain Applications......Page 253 The Layered Architecture......Page 254 Deployment Options......Page 255 Which Option to Choose?......Page 258 Development Activities......Page 261 Configuration Management......Page 264 Working Effectively......Page 267 Using Naked Objects Only in Development......Page 271 Decoupling from the Framework......Page 272 Programming Model Interaction Protocol......Page 276 Changing the Programming Model......Page 278 Integrating with Web Frameworks......Page 281 Deploying an Embedded Metamodel......Page 282 Integrating Layers with the Custom Presentation Option......Page 293 Integrating with the Database......Page 299 Configuring XML Persistence......Page 300 Mapping Entities Using JPA Annotations......Page 302 Mapping Value Objects Using JPA Annotations......Page 308 Mapping Relationships......Page 310 Porting over Repositories......Page 314 Deploying and Running the Application......Page 317 Integrating Within the Enterprise......Page 323 Bounded Context Patterns......Page 324 Exposing a RESTful Web Service for Other Systems......Page 326 Integrating Using an Enterprise Service Bus......Page 332 Deploying the Application......Page 345 Securing the Application......Page 354 Deploying the Sister Projects......Page 359 A CarServ Retrospective......Page 364 The DSFA Application......Page 365 Closing Thoughts......Page 366 Appendixes......Page 374 Programming Model Cheat Sheet......Page 375 Eclipse Templates......Page 379 Bibliography......Page 383 A......Page 386 B......Page 388 C......Page 389 D......Page 392 E......Page 394 F......Page 395 I......Page 396 J......Page 397 N......Page 398 O......Page 400 R......Page 401 S......Page 402 U......Page 404 W......Page 405 X......Page 406 Getting started Identifying the domain concepts Relating objects together Rapid prototyping Creating behaviorally complete objects Implementing business rules Using value types Isolating infrastructure services Distributing class responsibilities Applying domain patterns Keeping the model maintainable Scenario testing Developing domain applications Naked objects as a design tool Integrating with web frameworks Integrating with the database Integrating within the enterprise Deploying the full runtime. Focuses on what matters in enterprise applications: the core business domain. Using object-oriented principles, this title lets you develop a domain model that team members - including business experts and technical specialists - can understand.