<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5360527572884639261</id><updated>2025-04-21T09:58:36.990+02:00</updated><category term="design pattern"/><category term="cqrs"/><category term="ddd"/><category term="framework"/><category term="gwt"/><category term="java"/><category term="mvp"/><title type='text'>E-SoftLearning</title><subtitle type='html'>Discovering, Brainstorming, Improvement &amp;amp; Acting.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://e-softlearning.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5360527572884639261/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://e-softlearning.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04613185459873469938</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5360527572884639261.post-4818663576175170402</id><published>2011-07-29T05:56:00.001+02:00</published><updated>2011-07-29T05:58:41.272+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ddd"/><category scheme="http://www.blogger.com/atom/ns#" term="design pattern"/><category scheme="http://www.blogger.com/atom/ns#" term="framework"/><title type='text'>Domain Driven Design and Development In Practice</title><content type='html'>&lt;h2 style=&quot;background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; color: black; font-size: 19px; font: normal normal bold 1em/normal arial; letter-spacing: -1px; line-height: 16px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 0px; padding-right: 160px; padding-top: 4px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Background&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain Driven Design (DDD) is about mapping business domain concepts into software artifacts. Most of the writings and articles on this topic have been based on Eric Evans&#39; book &quot;Domain Driven Design&quot;, covering the domain modeling and design aspects mainly from a conceptual and design stand-point. These writings discuss the main elements of DDD such as Entity, Value Object, Service etc or they talk about concepts like&amp;nbsp;&lt;a href=&quot;http://www.domainlanguage.com/ddd/index.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Ubiquitous Language&lt;/a&gt;, Bounded Context and Anti-Corruption Layer.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 13px; line-height: 16px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 13px; line-height: 16px;&quot;&gt;Business RulesThe objective of this article is to cover the domain modeling and design from a practical stand-point on how one would go about taking a domain model and actually implementing it. We will look at the guidelines, best practices, frameworks and tools that the technical leads and architects can use in the implementation effort. Domain Driven Design and Development is also influenced by several architectural, design, and implementation aspects such as:&lt;/span&gt;&lt;br /&gt;
&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Persistence&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Caching&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Transaction Management&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Security&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Code Generation&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Test Driven Development&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Refactoring&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;This article talks about how these different factors affect the implementation project throughout its lifecycle and what the architects should look for in realizing a successful DDD implementation. I will start off with a list of characteristics a typical domain model should have, and when to use a domain model in an enterprise (versus not using a domain model at all or using an anemic domain model).&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The article includes a sample loan processing application to demonstrate how design aspects and development best practices discussed here, can be used in a real-world domain driven development project. The sample application uses frameworks like Spring, Dozer, Spring Security, JAXB, Arid POJOs and Spring Dynamic Modules in implementing the loan processing domain model. The example code will be in Java, but it should be fairly easy to understand for most developers, regardless of language background.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Introduction&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;A domain model offers several benefits some of which are:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;It helps the team create a common model, between the business and IT stakeholders in the company, that the team can use to communicate about the business requirements, data entities, and process models.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The model is modular, extensible and easy to maintain as the design reflects the business model.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;It improves the reusability and testability of the business domain objects.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;On the flip side, let&#39;s see what happens when IT teams don&#39;t follow a domain model approach for developing medium to large size enterprise software applications.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Not investing in a domain model and development effort leads to an application architecture with a &quot;Fat Service Layer&quot; and an &quot;Anemic Domain Model&quot; where facade classes (usually Stateless Session Beans) start accumulating more and more business logic and domain objects become mere data carriers with getters and setters. This approach also leads to domain specific business logic and rules being scattered (and duplicated in some cases) in several different facade classes.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Anemic domain models, in most cases, are not cost-effective; they don&#39;t give the company a competitive advantage over other companies because implementing business requirement changes in this architecture take too long to develop and deploy to production environment.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Before we look at different architectural and design considerations in a DDD implementation project, let&#39;s take a look at the characteristics of a rich domain model.&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The domain model should focus on a specific business operational domain. It should align with the business model, strategies and business processes.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;It should be isolated from other domains in the business as well as other layers in the application architecture.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;It should be reusable to avoid any duplicate models and implementations of the same core business domain elements.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The model should be designed loosely coupled with other layers in the application, meaning no dependencies on the layers on either side of domain layer (i.e. database and facade layers).&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;It should be an abstract and cleanly separated layer enabling easier maintenance, testing, and versioning. The domain classes should be unit testable outside the container (and from inside the IDE).&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;It should be designed using a POJO programming model without any technology or framework dependencies (I always tell the project teams I work with in my company, that the technology we use for software development is Java).&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The domain model should be independent of persistence implementation details (although the technology does place some constraints on the model).&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;It should have minimum dependencies on any infrastructure frameworks because it will outlive these frameworks and we don&#39;t want any tight coupling on any external framework.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;In order to achieve a better Return On Investment (ROI) on software development efforts, the senior management in Business Units and IT has to commit to the investment (of time, money, and resources) in business domain modeling and its implementation. Let&#39;s look at some of the other factors that are required for implementing a domain model.&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The team should have regular access to business domain subject matter experts.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;IT team (modelers, architects, and developers) should possess good modeling and design skills.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Analysts should have good business process modeling skills.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Architects and developers should have strong Object Oriented Design (OOD) and Programming (OOP) experience.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px; line-height: 16px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px; line-height: 16px;&quot;&gt;Role of Domain Driven Design in Enterprise Architecture&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain modeling and DDD play a vital role in Enterprise Architecture (EA). Since one of the goals of EA is to align IT with the business units, the domain model which is the representation of business entities, becomes a core part of EA. This is why most of the EA components (business or infrastructural) should be designed and implemented around the domain model.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Domain Driven Design and SOA&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Service Oriented Architecture (SOA) is gaining more and more momentum in the recent past to help the teams build software components and services based on the business processes and to speed up the time to market for the new products. Domain driven design is a key element of SOA architecture because it helps in encapsulating the business logic and rules in domain objects. The domain model also provides the language and context with which the service contract can be defined.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;An SOA effort should include the design and implementation of the domain model if one doesn&#39;t already exist. If we put too much emphasis on the SOA services and ignore the importance of domain model, we will end up with an anemic domain model and bloated services in the application architecture.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;An ideal scenario is the one where DDD effort is implemented iteratively with developing the application layer and SOA components at the same time as these are the direct consumers of domain model elements. With a rich domain implementation, SOA design will become relatively simple by providing a shell (proxy) to the domain objects. But if we focus too much on the SOA layer without a decent domain model in the back-end, the business services will be calling an incomplete domain model, which can result in a brittle SOA architecture.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Project Management&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;A domain modeling project typically includes the following steps:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Model and document business processes first.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Select a candidate business process and work with the business domain experts to document it using the Ubiquitous Language.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Identify all the services that are required for the candidate business process. These services can be atomic (single step) or orchestrated (multi-step with or without work-flow) in nature. They can also be business (e.g. Underwriting or Funding) or infrastructure (e.g. E-mail or Job Scheduling).&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Identify and document the state and behavior of the objects used by services identified in the previous step.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;It&#39;s important to keep the model at a high-level initially focusing on the core elements of the business domain.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;From a project management stand-point, a real-world DDD implementation project comprises the same phases as any other software development project. These phases include:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Model the domain&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Design&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Development&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Unit and Integration Testing&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Refine and refactor the domain model based on the design and development (Continuous Integration (CI) of model concepts).&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Repeat the above steps using the updated domain model (CI of domain implementation).&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;An agile software development methodology is a great fit here because agile methodologies focus on the delivery of business value just like DDD focuses on the alignment of software system with business model. Also, with the iterative nature of DDD, agile methodologies such as SCRUM or DSDM are better frameworks to manage the project. Using SCRUM (for project management) and XP (for software development purposes) methodologies is a good combination for managing a DDD implementation project.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;This project management model of DDD iteration cycle is shown in Figure 1 below.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgv45D4OAYGhcjgg9Vsd2oTTch6VxP-CbJE28VvybCeuWDid9XjDp1P8C_5pLKjpfCpavJ3oJHd3CFP920n7QHo9ccDCDvB9mStH9kKjOtkV34wCODTAv1vOMH46oXYUgBj25_4ZnDDdhPP/s1600/DDDImplementationCycleDiagram_lg.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;458&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgv45D4OAYGhcjgg9Vsd2oTTch6VxP-CbJE28VvybCeuWDid9XjDp1P8C_5pLKjpfCpavJ3oJHd3CFP920n7QHo9ccDCDvB9mStH9kKjOtkV34wCODTAv1vOMH46oXYUgBj25_4ZnDDdhPP/s640/DDDImplementationCycleDiagram_lg.gif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;em&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: center;&quot;&gt;&lt;em&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Figure 1. DDD Iteration cycle diagram&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;em&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain driven design effort begins where domain modeling ends. Ramnivas Laddad&amp;nbsp;&lt;a href=&quot;http://www.springone.com/display/SpringOne06/Domain+Driven+Design+with+AOP+and+DI&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;recommends the following steps&lt;/a&gt;&amp;nbsp;on how to go about implementing a domain object model. He emphasizes on putting more focus on domain objects than services in the domain model.&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Start with domain entities and domain logic.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Start without a service layer initially and only add services where the logic doesn&#39;t belong in any domain entity or value object.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Use Ubiquitous Language,&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Design_by_contract&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Design by Contract&lt;/a&gt;&amp;nbsp;(DbC), Automated Tests, CI and Refactoring to make the implementation as closely aligned as possible with the domain model.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;From the design and implementation stand-point, a typical DDD framework should support the following features.&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;It should be a POJO (or POCO if your company is a .NET shop) based framework.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;It should support the design and implementation of a business domain model using the DDD concepts.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;It should support concepts like Dependency Injection (DI) and Aspect Oriented Programming (AOP) out of the box. (Note: These concepts are explained in more detail later in the article).&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Integration with unit testing frameworks such as&amp;nbsp;&lt;a href=&quot;http://www.junit.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;JUnit&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://testng.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;TestNG&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://www.unitils.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Unitils&lt;/a&gt;&amp;nbsp;etc.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Good integration with other Java/Java EE frameworks like JPA, Hibernate, TopLink etc.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 16px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; color: black; font-size: 19px; font: normal normal bold 1em/normal arial; letter-spacing: -1px; line-height: 16px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 0px; padding-right: 160px; padding-top: 4px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Sample Application&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The sample application used in this article is a home loan processing system and the business use case is to approve the funding request of a home loan (mortgage). When a loan application is submitted to a mortgage lending company, it first goes through the Underwriting process where the underwriters approve or deny the loan request based on customer&#39;s income details, credit history and other factors. If the loan application is approved by underwriting group, it goes through Closing and Funding steps in the loan approval process.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Funding module in the loan processing system automates the process of disbursement of funds to the borrower. The funding process typically starts with mortgage lender (typically a bank) forwarding the loan package to a title company. The title company then reviews the loan package and schedules a date with seller and buyer of the property for closing the loan. Borrower and the seller meet with the closing agent at the title company to sign the paperwork to transfer the title of the property.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Architecture&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;A typical enterprise application architecture consists of the following four conceptual layers:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;strong&gt;User Interface&lt;/strong&gt;&amp;nbsp;(Presentation Layer): Responsible for presenting information to the user and interpreting user commands.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt;&amp;nbsp;This layer coordinates the application activity. It doesn&#39;t contain any business logic. It does not hold the state of business objects, but it can hold the state of an application task&#39;s progress.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;strong&gt;Domain Layer:&lt;/strong&gt;&amp;nbsp;This layer contains information about the business domain. The state of business objects is held here. Persistence of the business objects and possibly their state is delegated to the infrastructure layer.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;strong&gt;Infrastructure Layer:&lt;/strong&gt;&amp;nbsp;This layer acts as a supporting library for all the other layers. It provides communication between layers, implements persistence for business objects, contains supporting libraries for the user interface layer, etc.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Let&#39;s look at the application and domain layers in more detail. The Application layer:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;is responsible for the navigation between the UI screens in the application as well as the interaction with the application layers of other systems.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;can also perform the basic (non-business related) validation on the user input data before transmitting it to the other (lower) layers of the application.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;doesn&#39;t contain any business or domain related logic or data access logic.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;doesn&#39;t have any state reflecting a business use case but it can manage the state of the user session or the progress of a task.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The domain layer:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;is responsible for the concepts of business domain, information about the business use case and the business rules. Domain objects encapsulate the state and behavior of business entities. Examples of business entities in a loan processing application are Mortgage, Property, and Borrower.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;can also manage the state (session) of a business use case if the use case spans multiple user requests (e.g. loan registration process which consists of multiple steps: user entering the loan details, system returning the products and rates based on the loan parameters, user selecting a specific product/rate combination, and finally the system locking the loan for that rate).&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;contains service objects that only have a defined operational behavior which is not part of any domain object. Services encapsulate behavior of the business domain that doesn&#39;t fit in the domain objects themselves.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;is the heart of the business application and should be well isolated from the other layers of the application. Also, it should not be dependent on the application frameworks used in the other layers (JSP/JSF,&amp;nbsp;&lt;a href=&quot;http://struts.apache.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Struts&lt;/a&gt;, EJB,&amp;nbsp;&lt;a href=&quot;http://www.hibernate.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Hibernate&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://xmlbeans.apache.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;XMLBeans&lt;/a&gt;&amp;nbsp;and so-on).&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Figure 2 below shows the different architecture layers used in the application and how they relate to DDD.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR1HAcZrMGr5VLKm4esPXmOyiZEfZFofjKnJBuCZIgCLXGNrxrDOVcCRi1W4BO8tuIOhCdTCKTaCZCG_3moukPp_dByHarXv2JlJCKBxCjTzt1EoffxDzxYlkjXFB0SEdgGAijY026wkN1/s1600/ArchitectureDiagram_lg.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;516&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR1HAcZrMGr5VLKm4esPXmOyiZEfZFofjKnJBuCZIgCLXGNrxrDOVcCRi1W4BO8tuIOhCdTCKTaCZCG_3moukPp_dByHarXv2JlJCKBxCjTzt1EoffxDzxYlkjXFB0SEdgGAijY026wkN1/s640/ArchitectureDiagram_lg.gif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;em&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: center;&quot;&gt;&lt;em&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Figure 2. Layered Application Architecture diagram&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;em&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Following design aspects are considered as the main ingredients of the current DDD implementation recipe:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Object Oriented Programming (&lt;a href=&quot;http://en.wikipedia.org/wiki/Object_oriented&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;OOP&lt;/a&gt;)&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Dependency Injection (&lt;a href=&quot;http://www.martinfowler.com/articles/injection.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;DI&lt;/a&gt;)&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Aspect Oriented Programming (&lt;a href=&quot;http://www.eclipse.org/aspectj/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;AOP&lt;/a&gt;)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;OOP is the most important element in the domain implementation. Domain objects should be designed using Plain Java Classes and Interfaces by taking advantage of OOP concepts like inheritance, encapsulation, and polymorphism. Most of the domain elements are true objects with both State (attributes) and Behavior (methods or operations that act on the state). They also correspond to real world concepts and can fit right in with OOP concepts. Entities and Value Objects in DDD are classic examples of OOP concepts since they have both state and behavior.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;In a typical Unit of Work (UOW), domain objects need to collaborate with other objects whether they are Services, Repositories or Factories. Domain objects also need to manage other concerns such as domain state change tracking, auditing, caching, transaction management (including transaction retry) which are cross-cutting in nature. These are reusable non-domain related concerns that typically tend to be scattered and duplicated all over the code including the domain layer. Embedding this logic in the domain objects leads to tangling and cluttering of the domain layer with non-domain related code.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;When it comes to managing the code dependencies without tight-coupling between objects and isolating cross-cutting concerns, OOP alone cannot provide an elegant design solution for domain driven design and development. This is where design concepts like DI and AOP can be used to complement OOP to minimize tight coupling, enhance modularity and better manage the cross-cutting concerns.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Dependency Injection&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DI is a great way to move the configuration and dependency code out of the domain objects. Also, the design dependency of domain classes on Data Access Object (DAO) classes and service classes on domain classes makes DI a &quot;must have&quot; in DDD implementation. DI facilitates a cleaner and loosely coupled design by injecting the other objects such as Repositories and Services into Domain Objects.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;In the sample application, the service object (FundingServiceImpl) uses DI to inject the Entity objects (Loan, Borrower and FundingRequest). Also, Entities reference Repositories via DI. Similarly, other Java EE resources like&amp;nbsp;&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/javax/sql/DataSource.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;DataSource&lt;/a&gt;, Hibernate&amp;nbsp;&lt;a href=&quot;http://www.hibernate.org/hib_docs/v3/api/org/hibernate/SessionFactory.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Session Factory&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href=&quot;http://java.sun.com/javaee/5/docs/api/javax/transaction/TransactionManager.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Transaction Manager&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&amp;nbsp;are injected into Service and Repository objects.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Aspect Oriented Programming&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;AOP helps in an even better design (i.e. less cluttering in the domain model) by removing the cross-cutting concerns code like auditing, domain state change tracking etc from the domain objects. It can be used to inject collaborating objects and services into domain objects especially the objects that are not instantiated by the container (such as the persistence objects). Other aspects in the domain layer that could use AOP are caching, transaction management and role based security (authorization).&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Loan processing application uses custom Aspects to introduce data caching into the Service objects. Loan product and interest rate information is loaded from the database table once (the first this information is requested by the client) and is then stored in an object cache (&lt;a href=&quot;http://www.jboss.org/jbosscache/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;JBossCache&lt;/a&gt;) for subsequent product and rate lookups. Product and rate data is frequently accessed but it&#39;s not updated that regularly, so it&#39;s a good candidate for caching the data instead of hitting the back-end database every time.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The role of DI and AOP concepts in DDD was the main topic in a recent discussion thread. The discussion was based on a presentation by Ramnivas Laddad where he made the assertion that&amp;nbsp;&lt;a href=&quot;http://www.springone.com/display/SpringOne06/Domain+Driven+Design+with+AOP+and+DI&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;DDD cannot be implemented without help of AOP and DI&lt;/a&gt;. In the presentation, Ramnivas talked about the concept of &quot;fine grained DI&quot; using AOP to make domain objects regain smart behavior. He mentioned that domain objects need access to other fine grained objects to provide rich behavior and a solution to this is to inject Services, Factories, or Repositories into Domain Objects (by using Aspects to inject dependency at constructor or setter invocation time).&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Chris Richardson also discussed about&amp;nbsp;&lt;a href=&quot;http://chris-richardson.blog-city.com/cleaning_up_your_code_with_real_objects_dependency_injectio.htm&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;using DI, objects, and Aspects&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&amp;nbsp;to improve the application design by reducing coupling and increasing modularity. Chris talked about &quot;Big Fat Service&quot; anti-pattern which is the result of coupling, tangling and scattering of the application code and how to avoid it using DI and AOP concepts.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Annotations&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;A recent trend to define and manage Aspects and DI is to use Annotations. Annotations help in minimizing the required artifacts for implementing the remote services such as EJB or Web Services. They also simplify the configuration management tasks.&amp;nbsp;&lt;a href=&quot;http://static.springframework.org/spring/docs/2.5.x/reference/index.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Spring 2.5&lt;/a&gt;,&lt;a href=&quot;http://www.hibernate.org/hib_docs/v3/reference/en/html/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Hibernate 3&lt;/a&gt;&amp;nbsp;and other frameworks take full advantage of Annotations to configure the components in different layers of a Java enterprise application.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;We should take advantage of annotations to generate the boiler plate code where it adds value in terms of flexibility. At the same time, annotations should be used with some caution. They should be used where they are not confusing or misleading in understanding the actual code. A good example of using Annotation is Hibernate ORM mapping where it adds value to specify the SQL table or column name right next to the class or attribute name. On the other hand, details like JDBC driver configuration (driver name, jdbc url, user name, and password) are better suited to be stored in an XML file rather than using Annotations. This is based on the assumption that the database is in the same context. If significant transformations are required between the domain model and the database tables, then the design should take that concern into consideration.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;a href=&quot;http://java.sun.com/javaee/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Java EE 5&lt;/a&gt;&amp;nbsp;provides JPA annotations like&amp;nbsp;&lt;a href=&quot;http://java.sun.com/javaee/5/docs/api/javax/persistence/Entity.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;@Entity&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://java.sun.com/javaee/5/docs/api/javax/persistence/PersistenceUnit.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;@PersistenceUnit&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://java.sun.com/javaee/5/docs/api/javax/persistence/PersistenceContext.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;@PersistenceContext&lt;/a&gt;, etc. to add persistence details to plain Java classes. In the context of domain modeling, Entity, Repository and Service are good candidates for using Annotations.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;a href=&quot;http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/beans/factory/annotation/Configurable.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;@Configurable&lt;/a&gt;&amp;nbsp;is Spring&#39;s way of injecting Repository and Services into a Domain Object. Spring framework extends the &quot;Domain Object DI&quot; idea beyond the @Configurable annotation. Ramnivas recently blogged about the&amp;nbsp;&lt;a href=&quot;http://blog.springsource.com/main/2008/01/23/new-improvements-in-domain-object-dependnecy-injection-feature/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;latest improvements&lt;/a&gt;&amp;nbsp;in upcoming Spring 2.5.2 release (available starting with project snapshot build 379). There are three new aspects (AnnotationBeanConfigurerAspect, AbstractInterfaceDrivenDependencyInjectionAspect, and AbstractDependencyInjectionAspect) to provide simple and more flexible options for Domain Object DI. Ramnivas said the main reason behind introducing the middle aspect (AbstractInterfaceDrivenDependencyInjectionAspect) is to allow domain-specific annotations and interfaces to play a role. Spring also provides other annotations like&amp;nbsp;&lt;a href=&quot;http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/stereotype/Repository.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;@Repository&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/stereotype/Service.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;@Service&lt;/a&gt;, and&amp;nbsp;&lt;a href=&quot;http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/transaction/annotation/Transactional.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;@Transactional&lt;/a&gt;&amp;nbsp;to help in the design of the domain classes.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Some of the annotations used in the sample application, Entity objects (Loan, Borrower, and FundingRequest) use @Entity annotation. These objects also use @Configurable annotation to wire the Repository objects. And the Service classes use @Transactional annotation to decorate the service methods with transactional behavior.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Domain model and Security&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Application security in the domain layer ensures only authorized clients (human users or other applications) are calling the domain operations as well as accessing the domain state.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;a href=&quot;http://static.springframework.org/spring-security/site/index.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Spring Security&lt;/a&gt;&amp;nbsp;(a sub-project in Spring Portfolio) provides a fine-grained access control in both presentation (URL based) and domain (Method Level) layers of the application. The framework uses Spring&#39;s Bean Proxy to intercept method invocation and apply security constraints. It offers a role-based declarative security for Java objects using&amp;nbsp;&lt;a href=&quot;http://static.springframework.org/spring-security/site/apidocs/org/springframework/security/intercept/method/aopalliance/MethodSecurityInterceptor.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;MethodSecurityInterceptor&lt;/a&gt;&amp;nbsp;class. There is also instance level security in the form of Access Control Lists (ACL&#39;s) for domain objects to control the user access at the instance level.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The main advantage of using Spring Security for managing the authorization requirements in the domain model is that the framework has a non-invasive architecture so we can have a clean separation between the domain and security aspects. Also, the business objects are not cluttered with security implementation details. We can write common security rules in one place and apply them (using AOP techniques) wherever they need to be implemented.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;In domain and service classes, authorization is managed at the class method invocation level. For example, the &quot;loan approval&quot; method in an Underwriting domain object can be invoked by any user with an &quot;Underwriter&quot; role for loans up to 1 million dollars whereas the approval method in the same domain object for loan applications with a loan amount greater than 1 million dollars can only be called by a user with &quot;Underwriting Supervisor&quot; role.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The following table is a summary of various application security concerns in each layer of the application architecture.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Table 1. Security Concerns in Various Application Layers&lt;/span&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;1&quot; cellspacing=&quot;0&quot; style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Layer&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Security Concern&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Client/Controller&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Authentication, Web Page (URL) Level Authorization&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Facade&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Role based authorization&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain instance level authorization, ACL&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Database&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DB object level authorization (Stored procedures, Stored functions, Triggers)&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h3 style=&quot;font-size: 15px; font: normal normal bold 1em/normal arial; letter-spacing: -1px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;font-size: 15px; font: normal normal bold 1em/normal arial; letter-spacing: -1px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Business Rules&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;font-size: 15px; font: normal normal bold 1em/normal arial; letter-spacing: -1px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 13px; font-weight: normal; letter-spacing: normal;&quot;&gt;Business rules are an important part of the business domain. They define data validation and other constraints that need to be applied on domain objects in specific business process scenarios. Business rules typically fall into the following categories:&lt;/span&gt;&lt;/h3&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Data validation&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Data transformation&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Business decision-making&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Process routing (work-flow logic)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The context is very important in DDD world. Context specificity dictates the domain object collaboration as well as other run-time factors like what business rules to apply etc. Validation and other business rules are always processed in a specific business context. This means the same domain object, in a different business context, will have to process different set of business rules. For example, some attributes of a loan domain object (such as loan amount and interest rate) cannot be changed after the loan has been through the Underwriting step in the loan approval process. But the same attributes can be changed when the loan is just registered and locked for a specific interest rate.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Even though all the domain specific business rules should be encapsulated in the domain layer, some application designs put the rules in facade classes, which leads to domain classes becoming &quot;anemic&quot; in terms of business rules logic. This may be an acceptable solution in small size applications, but it is not recommended for mid-size to large enterprise applications that contain complex business rules. A better design option is to put the rules where they belong, inside the domain objects. If a business rule logic spans two or more Entity objects, then it should become part of a Service class.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Also, if we are not diligent in the application, design business rules will end up being coded in the form of several switch statements in the code. And over time as the rules get more complex, developers don&#39;t take time to refactor the code to move &quot;switch&quot; statements into a more manageable design. Hardcoding the complex routing or decision-making rules logic in the classes leads to longer methods in the classes, code duplication, and ultimately a rigid application design which will become a maintenance nightmare in the long run. A good design is to place all the rules (especially complex rules that change frequently as the business strategy changes) into a Rules engine (using a rules framework like&amp;nbsp;&lt;a href=&quot;http://www.jboss.org/drools/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;JBoss Rules&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://openrules.com/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;OpenRules&lt;/a&gt;, or&amp;nbsp;&lt;a href=&quot;http://mandarax.sourceforge.net/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Mandarax&lt;/a&gt;) and invoke them from the domain classes.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Validation rules are usually implemented in different languages like Javascript, XML, Java code, and other scripting languages. But due to the dynamic nature of business rules, scripting languages such as&amp;nbsp;&lt;a href=&quot;http://www.ruby-lang.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Ruby&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://groovy.codehaus.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Groovy&lt;/a&gt;, or&amp;nbsp;&lt;a href=&quot;http://www.martinfowler.com/bliki/DomainSpecificLanguage.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Domain Specific Languages&lt;/a&gt;&amp;nbsp;(DSL) are a better choice to define and manage these rules. Struts (Application layer), Spring (Service) and Hibernate (ORM) all have their own validation modules where we can apply the validation rules on the incoming or outgoing data objects. In some cases, validation rules can also be managed as Aspects (link AOP rules article here) that can be weaved into different layers (e.g. Service and Controller) of the application.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;It&#39;s important to keep in mind the unit testing aspect when writing the domain classes to manage business rules. Any changes in the rules logic should be easily unit testable in isolation.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The sample application includes a business rule set to validate the loan parameters are within the allowed product and rate specifications. The rules are defined in a scripting language (Groovy) and are applied on the loan data passed to FundingService object.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Design&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;From a design stand-point, the domain layer should have a well defined boundary to avoid the corruption of the layer from non-core domain layer concerns such as vendor-specific translations, data filtering, transformations, etc. Domain elements should be designed to hold the domain state and behavior correctly. Different domain elements are structured differently based on state and behavior. Table 2 below shows the domain elements and what they contain.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Table 2. Domain elements with state and behavior&lt;/span&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;1&quot; cellspacing=&quot;0&quot; style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain Element&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;State/Behavior&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Entity, Value Object, Aggregate&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;State and Behavior&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Data Transfer Object&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;State only&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Service, Repository&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Behavior only&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Entities, Value Objects, and Aggregates which contain both state (data) and behavior (operations), should have clearly defined state and behavior. At the same time, this behavior should not extend beyond the limits of the object&#39;s boundaries. Entities should do most of the work in the use case acting on their local state. But they shouldn&#39;t know about too many unrelated concepts.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Good design practice is to only include the getters/setters for the attributes that are required to encapsulate the state of domain objects. When designing the domain objects, only provide setter methods for those fields that can change. Also, the public constructors should contain only the required fields instead of a constructor with all the fields in the domain class.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;In most of the use cases, we don&#39;t really have to be able to change the state of an object directly. So, instead of changing the internal state, create a new object with the changed state and return the new object. This is sufficient in these use cases and it also reduces design complexity.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Aggregate classes hide the usage of collaborating classes from callers. They can be used for encapsulating complex, intrusive, and state-dependent requirements in the domain classes.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Design Patterns that Support DDD&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;There are several design patterns that help in domain driven design and development. Following is a list of these design patterns:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain Object (DO)&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Data Transfer Object (DTO)&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DTO Assembler&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Repository: The Repository contains domain-centric methods and uses the DAO to interact with the database.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Generic DAO&#39;s&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Temporal Patterns: These patterns add time dimension to rich domain models.&amp;nbsp;&lt;a href=&quot;https://svn.ervacon.com/public/projects/bitemporal/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Bitemporal framework&lt;/a&gt;, which is based on Martin Fowler&#39;s&amp;nbsp;&lt;a href=&quot;http://www.martinfowler.com/eaaDev/timeNarrative.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Temporal Patterns&lt;/a&gt;, provides a design approach to dealing with bitemporal issues in the domain models. The core domain objects and their bitemporal properties can be persisted using an ORM product such as Hibernate.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Other design patterns that are used in DDD include Strategy, Facade, and Factory. Jimmy Nilsson discussed Factory as one of the domain patterns in his&amp;nbsp;&lt;a href=&quot;http://www.jnsk.se/adddp/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;book&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;DDD Anti-Patterns&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;On the flip side of the best practices and design patterns, there are some DDD smells that architects and developers should watch out for when implementing the domain model. As a result of these anti-patterns, domain layer becomes the least important part in application architecture and facade classes assume a more important role in the model. Following are some of these anti-patterns:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Anemic domain objects&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Repetitive DAO&#39;s&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Fat Service Layer: This is where service classes will end up having all the business logic.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Feature Envy: This is one of the classic smells mentioned in Martin Fowler&#39;s&amp;nbsp;&lt;a href=&quot;http://www.martinfowler.com/books.html#refactoring&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;book&lt;/a&gt;&amp;nbsp;on Refactoring where the methods in a class are far too interested in data belonging to other classes.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px; line-height: 16px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px; line-height: 16px;&quot;&gt;Data Access Objects&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DAO&#39;s and Repositories are also important in domain driven design. DAO is the contract between relational database and the application. It encapsulates the details of database CRUD operations from the web application. On the other hand, a Repository is a separate abstraction that interacts with the DAOs and provides &quot;business interfaces&quot; to the domain model.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Repositories speak the Ubiquitous Language of the domain, work with all necessary DAOs and provide data access services to the domain model in a language the domain understands.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DAO methods are fine-grained and closer to the database while the Repository methods are more coarse-grained and closer to the domain. Also one Repository class may have multiple DAO&#39;s injected. Repositories and DAO&#39;s keep the domain model decoupled from dealing with the data access and persistence details.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The domain objects should depend only on Repository interfaces. This is the reason why injecting the Repository instead of a DAO results in a much cleaner domain model. DAO classes should never be called directly from the client (Services and other consumer classes). The clients should always call the domain objects which in turn should call the DAO&#39;s for persisting the data to the data store.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Managing the dependencies between domain objects (for example, the dependency between an Entity and its Repository) is a classic problem that developers often run into. The usual design solution to this problem is to have the Service or Facade class call a Repository directly and when invoked the Repository would return the Entity object to the client. This design eventually leads to the afore-mentioned Anemic Domain Model where facade classes start accumulating more business logic and domain objects become mere data carriers. A good design is to inject Repositories and Services into domain objects using DI &amp;amp; AOP techniques.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Sample application follows these design principles in implementing the loan processing domain model.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Persistence&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Persistence is an infrastructural aspect from which the domain layer should be decoupled. JPA provides this abstraction by hiding the details of the persistence implementation from the classes. It is annotation driven so no XML mapping files are required. But at the same time, the table and column names are embedded in the code which may not be a flexible solution in some cases.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;With grid computing products such as Oracle&amp;nbsp;&lt;a href=&quot;http://www.oracle.com/products/middleware/coherence/index.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Coherence&lt;/a&gt;, WebSphere Object Grid, and&amp;nbsp;&lt;a href=&quot;http://www.gigaspaces.com/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;GigaSpaces&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&amp;nbsp;that offer data grid solutions, the developers don&#39;t even need to think about a RDBMS when they model and design the business domain. The database layer is abstracted from domain layer in the form of an in-memory Object/Data Grid.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Caching&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;When we talk about the state (data) of the domain layer, we have to talk about the aspect of caching. Frequently accessed domain data (such as products and rates in a mortgage loan processing application) are good candidates for caching. Caching speeds up the performance and reduces the load on the database server. Service layer is ideal for caching the domain state. ORM frameworks like&lt;a href=&quot;http://www.oracle.com/technology/products/ias/toplink/index.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;TopLink&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href=&quot;http://www.hibernate.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Hibernate&lt;/a&gt;&amp;nbsp;also provide data caching.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Loan processing sample application uses JBossCache framework to cache product and rate details to minimize the database calls and improve application performance.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Transaction Management&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Transaction management is important to keep the data integrity and to commit or rollback the UOW as a whole. There has always been a debate about where the transactions should be managed in the application architecture layers. There are also the cross-entity transactions (that span multiple domain objects in the same UOW) that affect the design decision of where the transactions should be managed.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Some developers prefer managing the transactions in the DAO classes which is a poor design. This results in too fine-grained transaction control which doesn&#39;t give the flexibility of managing the use cases where the transactions span multiple domain objects. Service classes should handle transactions; this way even if the transaction spans multiple domain objects, the service class can manage the transaction since in most of the use cases the Service class handles the control flow.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;FundingServiceImpl class in the sample application manages transactions for the funding request and executes multiple database operations by calling the Repositories and commits or rolls back all database changes in a single transactions.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Data Transfer Objects&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DTO&#39;s are also an important part of the design in an SOA environment where the Domain object model structurally is not compatible with the messages that are received and sent from a business service. The messages are typically defined and maintained in as XML Schema Definition documents (XSD&#39;s) and it&#39;s a common practice to write (or code generate) DTO objects from the XSD&#39;s and use them for data (message) transfer purposes between domain and SOA service layers. Mapping the data from one or more domain objects to a DTO will become a necessary evil in distributed applications where sending the domain objects across the wire may not be practical from a performance and a security stand-point.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;From a DDD perspective, DTO&#39;s also help maintain the separation between Service and UI layers where DO&#39;s are used in the domain and service layers and DTO&#39;s are used in the presentation layer.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;a href=&quot;http://dozer.sourceforge.net/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Dozer&lt;/a&gt;&amp;nbsp;framework is used for the assembly of one or more domain objects into a DTO object. It is bi-directional which saves a lot of extra code and time when converting domain objects into DTO&#39;s and vice-versa. The 2-way mapping between DO and DTO objects helps eliminate the separate DO -&amp;gt; DTO and DTO -&amp;gt; DO translation logic. The framework also correctly handles the type and array conversion.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The sample application uses Dozer mapping files (XML) to split the FundingRequestDTO object into Loan, Borrower, and FundingRequest Entity objects when the request comes in for fund processing. The mapping also takes care of the aggregation of the funding response data from the Entities into a single DTO object on the way back to the client.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;DDD Implementation Frameworks&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Frameworks like Spring and Real Object Oriented (&lt;a href=&quot;http://www.springone.com/display/SpringOne07/A+Fast+Hop+into+Real+Object+Oriented+Apps&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;ROO&lt;/a&gt;), Hibernate, and Dozer aid in designing and implementing a domain model. Other frameworks that support DDD implementation are&amp;nbsp;&lt;a href=&quot;http://jmatter.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;JMatter&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://www.nakedobjects.org/home/index.shtml&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Naked Objects&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://www.rubyonrails.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Ruby On Rails&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://grails.codehaus.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Grails&lt;/a&gt;, and Spring Modules&amp;nbsp;&lt;a href=&quot;https://springmodules.dev.java.net/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;XT Framework&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Spring takes care of instantiating and wiring together the domain classes such as Services, Factories, and Repositories. It also injects Services into Entities using @Configurable annotation. This annotation is Spring specific, so other options for achieving this injection is to use something like Hibernate Interceptor.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;ROO is a DDD implementation framework built on &quot;domain first and infrastructure second&quot; philosophy. The framework was developed to reduce the boiler-plate coding of the patterns found in web application development. When using ROO, we define the domain model, and then the framework (based on&amp;nbsp;&lt;a href=&quot;http://maven.apache.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Maven&lt;/a&gt;&amp;nbsp;Archetypes) generates the code for Model-View-Controller (MVC), DTO&#39;s, Business Layer Facade and DAO layers. It even generates the stubs for unit and integration tests.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;ROO has some very useful practical implementation patterns. For example, it distinguishes the state managed fields, the persistence layer uses field-level access, and the public constructors only reflect the mandatory fields.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Development&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;A model is no good without the actual implementation. The implementation phase should include automating the development tasks as much as possible. To see what tasks can be automated, let&#39;s look at a typical use case involving the domain model. Following is the list of steps in the use case:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Request In:&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Client calls a Facade class sending data as an XML document (which is XSD compliant); Facade class initiates a new transaction for the UOW.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Run validations on the incoming data. These validations include the primary (basic/data type/field level checks) and business validations. If there are any validation errors, raise appropriate exceptions.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Translate the descriptions to codes (to be domain friendly).&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Make the data formatting changes to be domain model friendly.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Make any separation of attributes (like splitting a customer name into first and last name attributes in a Customer Entity object).&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Disassemble the DTO data into one or more domain objects.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Persist the state of domain objects.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Response Out:&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Get the state of domain object(s) from datastore.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Cache the state if necessary.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Assemble the domain object(s) into application friendly data objects (DTO).&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Make any merge or separation of data elements (such as combining first and last names into single customer name attribute).&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Translate the codes into descriptions.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Make the data formatting changes necessary to address the client data usage requirements.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Cache the DTO state if necessary&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Transaction commits (or rolls back if there was an error) as the control flow exits.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The following table shows different objects that carry the data from one layer to another in the application.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Table 3. Data flow through the application layers&lt;/span&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;1&quot; cellspacing=&quot;0&quot; style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Layer&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;From Object&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;To Object&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Framework&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DAO&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Database Table(s)&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DO&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Hibernate&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain Delegate&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DO&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DTO&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Dozer&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Data Transfer&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DTO&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;XML&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;a href=&quot;https://jaxb.dev.java.net/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;JAXB&lt;/span&gt;&lt;/a&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;As you can see there are few layers in the application architecture where same data flows through in different forms (DO, DTO, XML, etc). Most of these objects (Java or XML) that hold data as well as other classes like DAO, DAOImpl, and DAOTest are infrastructural in nature. These classes and XML files that have boiler-plate code and structure are great candidates for code generation.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Code Generation&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Frameworks like ROO also create a standard and consistent project template (using Maven plugin) for new projects. Using a pre-generated project template, we can achieve consistency in the directory structure on where to store the source and test classes, configuration files, and dependencies on internal and external (third-party) component libraries.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;It could be overwhelming when we consider the myriad of classes and configuration files needed to develop a typical enterprise software application. Code generation is the best way to go about this problem. Code generation tools typically use some kind of template framework to define the templates or mappings from which a code generator can generate the code.&amp;nbsp;&lt;a href=&quot;http://www.eclipse.org/modeling/emf/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Eclipse Modeling Framework&lt;/a&gt;&amp;nbsp;(EMF) has several sub-projects that aid in the code generation of various artifacts required in a web application project. Model Driven Architecture (MDA) tools like AndroMDA use EMF to generate the code based on architecture models.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;When it comes to writing the delegate classes in domain layer I have seen developers writing these classes manually (mostly writing the first one from scratch and then following &quot;Copy And Paste&quot; pattern to create the required delegate classes for other domain objects. Since most of these classes are basically facades to domain classes they are good candidates for code generation. Code generation option is a good long-term solution even though it involves some initial investment (in terms of coding and time) to build and test the code generator (engine).&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;For the test classes generated, a good option is to create abstract methods for the methods with complex business logic in the main class that need to be unit tested. This way, developers can extend the generated base test class and implement custom business logic which cannot be auto-generated. The same goes for any test method that has testing logic which cannot be auto-created.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Scripting languages are a better choice for writing code generators as they have less overhead and they support template creation and customization options. If we take advantage of code generation in a DDD project, we only need to write a few classes from scratch. The artifacts that must be created from scratch include:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;XSD&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain Object&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Service&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Once we define the XSD and Java classes, we can code generate all or most of the following classes and configuration files:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DAO interface and implementation class&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Factories&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Repositories&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain Delegate (if needed)&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Facade (including EJB and WebService classes)&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DTO&#39;s&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Unit Tests for the above classes (including test class and test data)&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Spring configuration files&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Table 4 below lists different layers in a web application architecture and what artifacts (Java classes or XML files) can be generated in that layer.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Table 4: Code generation in DDD implementation project&lt;/span&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;1&quot; cellspacing=&quot;0&quot; style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Layer/Function&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Pattern&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Code You Write&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Generated Code&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Framework&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Data Access&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DAO/Repository&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DAO Interface,&lt;br /&gt;
DAO Implementation class,&lt;br /&gt;
DAOTest,&lt;br /&gt;
Test Seed Data&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Unitils,&lt;br /&gt;
DBUnit&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DO&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain class&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DomainTest&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Persistence&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;ORM&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain Class&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;ORM Mappings,&lt;br /&gt;
ORM Mapping Test&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Hibernate,&lt;br /&gt;
ORMUnit&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Data Transfer&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DTO&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;XSD&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DTO&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;JAXB&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DTO Assembly&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Assembler&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Mapping&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DO-DTO Mapping&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Dozer&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Delegate&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Business Delegate&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Code to translate DO&#39;s to DTO&#39;s&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Facade&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Facade&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Remote Service,&lt;br /&gt;
EJB,&lt;br /&gt;
Web Service&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Controller&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;MVC&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Controller Mapping Files&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Struts/Spring MVC&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Presentation&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;MVC&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;View configuration files&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Spring MVC&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;small&gt;&lt;/small&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Delegate layer is the only layer that has knowledge of both Domain Objects and DTO&#39;s. Other layers such as Persistence layer should be unaware of DTO&#39;s.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 15px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Refactoring&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Refactoring is changing or restructuring the application code without changing the functionality or behavior of the application. Refactoring can be either design or code related. Design refactoring is done to continually refine the model and refactor the code to improve the domain model.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Refactoring plays an important role in the DDD project due to its iterative and evolutionary nature of domain modeling. One way to integrate refactoring tasks into the project is to add it in each iteration of the project before calling the iteration done. Ideally, refactoring should be done before and after every development task.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Refactoring should be done with strict discipline. Use the combination of refactoring, CI, and unit testing to make sure the code changes didn&#39;t break any functionality and at the same time the changes did help with the intended code or performance improvements.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Automated tests play a vital role in refactoring the application code. Without good automated developer tests and&amp;nbsp;&lt;a href=&quot;http://c2.com/cgi/wiki?TestDrivenDevelopment&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Test Driven Development&lt;/a&gt;(TDD) practices, refactoring can be counter-productive since there will be no automated way to verify that the design and code changes made as part of refactoring effort didn&#39;t change the behavior or break the functionality.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Tools like&amp;nbsp;&lt;a href=&quot;http://www.eclipse.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Eclipse&lt;/a&gt;&amp;nbsp;help in implementing the domain model in an iterative way with refactoring as part of the development effort. Eclipse has features like extracting or moving a method to a different class or pushing down a method to a subclass. There are also several code analysis plugins for Eclipse that can help in managing the code dependencies and identifying the DDD anti-patterns. I rely on plugins like&lt;a href=&quot;http://clarkware.com/software/JDepend.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;JDepend&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://classycle.sourceforge.net/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Classycle&lt;/a&gt;, and&amp;nbsp;&lt;a href=&quot;http://metrics.sourceforge.net/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Metrics&lt;/a&gt;&amp;nbsp;when I do the design and code review of projects, to assess the quality of domain and other modules in the application.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Chris Richardson talked about&amp;nbsp;&lt;a href=&quot;http://chrisrichardson.net/sdforumjavasig0208.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;applying code refactoring&lt;/a&gt;&amp;nbsp;to transform a procedural design into an OO design using refactoring features provided by Eclipse.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Unit Testing/Continuous Integration&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;One of the goals we talked about earlier is that the domain classes should be unit testable (during the initial development as well as later when refactoring the existing code) without too many dependencies on the container or other infrastructure code. TDD approach helps the team in finding any design problems early in the project as well as verifying that the code is in alignment with domain model. DDD is ideal for Test-First development because the state and behavior are contained in domain classes and it should be easy to test them in isolation. It is important to test the state and behavior of domain model and not focus too much on the implementation details of data access or persistence.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Unit testing frameworks like JUnit or TestNG are great tools to implement and manage the domain model. Other testing frameworks like&lt;a href=&quot;http://www.dbunit.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;DBUnit&lt;/a&gt;&amp;nbsp;and Unitils can also be used to test domain layer especially to inject test data into DAO classes. This will minimize writing extra code for populating test data in unit test classes.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Mock objects also help in testing the domain objects in isolation. But it&#39;s important to not go crazy with using mock objects in the domain layer. If there are other easy ways to test domain classes, you should use those options instead of using mock objects. For example, if you can test an Entity class using a real DAO class in the back-end (instead of a mock DAO implementation) with an in-memory HSQL database instead of the real database; it will make the domain layer unit tests run quicker which is the main idea behind using mock objects any way. This way, you will be testing the collaboration (interaction) between domain objects as well as the state (data) exchanged between them. With mock objects, we will only be testing the interaction between the domain objects.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;All unit and integration tests created during the development phase (with or without using TDD practices) will become part of the automated test suite once the development tasks are done. These tests should be maintained and executed frequently in the local and higher development environments to find if the new code changes introduced any bugs into domain classes.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Eric Evans covers CI in his&amp;nbsp;&lt;a href=&quot;http://domaindrivendesign.org/books/index.html#DDD&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;book&lt;/a&gt;&amp;nbsp;saying that CI effort should always be applied within a Bounded Context and it should include the synchronization of people as well as code. CI tools like&amp;nbsp;&lt;a href=&quot;http://cruisecontrol.sourceforge.net/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;CruiseControl&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href=&quot;https://hudson.dev.java.net/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Hudson&lt;/a&gt;&amp;nbsp;can be used to set up an automatic build and test environment to run the application build script (created using a build tool such as&amp;nbsp;&lt;a href=&quot;http://ant.apache.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Ant&lt;/a&gt;&amp;nbsp;or Maven) to checkout the code from a SCM repository (like&amp;nbsp;&lt;a href=&quot;http://www.nongnu.org/cvs/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;CVS&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://subversion.tigris.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Subversion&lt;/a&gt;&amp;nbsp;etc), compile the domain classes (as well as the other classes in the application) and if there are no build errors, then automatically run all the tests (unit and integration). CI tools can also be setup to notify the project teams (via e-mail or RSS feeds) if there are any build or test errors.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Deployment&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain models are never static; they change as business requirements evolve during the lifecycle of the project and new requirements come up in the new projects. Also, as you develop and implement the domain model you constantly learn and improve, and you want to apply the new knowledge to the existing model.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Isolation is the key when packaging and deploying the domain classes. Since domain layer has dependencies on DAO layer on one side and Service Facade layer on the other (see the application architecture diagram in Figure 2), it makes lot of sense to package and deploy the domain classes as one or more modules to manage these dependencies elegantly.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;While design patterns such as DI, AOP and Factories minimize the coupling between the objects at design time and make the application modular,&amp;nbsp;&lt;a href=&quot;http://www.osgi.org/Main/HomePage&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;OSGi&lt;/a&gt;&amp;nbsp;(formerly known as Open Services Gateway initiative) addresses modularity at runtime. OSGi is becoming a standard mechanism to package and distribute the enterprise applications. It nicely handles the dependencies between the modules. We can also use OSGi for domain model versioning purposes.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;We can package DAO classes in one OSGi bundle (the DAO bundle), the service facade classes in another bundle (service bundle), so when DAO or Service implementations are modified or a different version of the application is being deployed, thanks to OSGi, no application restarts are required. We can also deploy two different versions of the same domain class if we have to support the existing and new versions of certain domain objects for backward compatibility.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;To take advantage of OSGi capabilities, the application objects have to be registered with OSGi platform before being consumed (i.e. before the client can do a lookup for them). This means that we have to use OSGi APIs to do the registration but we also have to deal with failure scenarios as services are started and stopped using OSGi container.&amp;nbsp;&lt;a href=&quot;http://www.springframework.org/osgi&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Spring Dynamic Modules&lt;/a&gt;&amp;nbsp;framework helps in this area by allowing any type of object to be exported and imported in the application without any code changes.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Spring DM also provides test classes to run OSGi integration tests outside the container. For example,&amp;nbsp;&lt;a href=&quot;http://static.springframework.org/osgi/docs/1.0.2/api/org/springframework/osgi/test/AbstractOsgiTests.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;AbstractOsgiTests&lt;/a&gt;&amp;nbsp;can be used to run integration tests directly from the IDE. The setup is handled by the testing infrastructure so we don&#39;t have to write a MANIFEST.MF file for the test, or do any packaging or deployment. The framework supports most of the OSGi implementations currently available (&lt;a href=&quot;http://www.eclipse.org/equinox/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Equinox&lt;/a&gt;,&lt;a href=&quot;http://www.knopflerfish.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Knopflerfish&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href=&quot;http://felix.apache.org/site/index.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Apache Felix&lt;/a&gt;).&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Loan processing application uses OSGi, Spring DM, and Equinox container to manage the module level dependencies and the deployment of domain and other modules. LoanAppDeploymentTests shows the use of Spring DM test module.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Sample Application Design&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The domain classes used in the loan processing sample application are listed below:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Entities:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Loan&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Borrower&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;UnderwritingDecision&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;FundingRequest&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Value Objects:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;ProductRate&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;State&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Services:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;FundingService&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Repositories:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;LoanRepository&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;BorrowerRepository&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;FundingRepository&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Figure 3 shows the domain model diagram for the sample application.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioQDI4WmfGrkG_9SEmtxjnixYFBtoY4OZbIbwEU4Ep9VGGYlYwwo7fS7ih24uS2T34hLIU2L0SzHxigJjb8yphQ-K0MwPfOiRIZ4Nj3QSBGbl2VRXl0bioOLB64C0zeNgXRTjg1fqo_vvI/s1600/LoanAppDomainModel_lg.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioQDI4WmfGrkG_9SEmtxjnixYFBtoY4OZbIbwEU4Ep9VGGYlYwwo7fS7ih24uS2T34hLIU2L0SzHxigJjb8yphQ-K0MwPfOiRIZ4Nj3QSBGbl2VRXl0bioOLB64C0zeNgXRTjg1fqo_vvI/s640/LoanAppDomainModel_lg.gif&quot; width=&quot;550&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;em&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: center;&quot;&gt;&lt;em&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Figure 3. Layered Application Domain Model&amp;nbsp;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;em&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Most of the DDD design concepts and techniques discussed in this article are applied in the sample application. Concepts like DI, AOP, Annotations, Domain Level Security, and Persistence are used. Also, I used several open source frameworks to help in DDD development and implementation tasks. These frameworks are listed below:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-size: 13px; line-height: 16px;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Spring&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Dozer&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Spring Security&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;JAXB (Spring-WS for marshalling and unmarshalling the data)&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Spring Testing (for unit and integration testing)&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DBUnit&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Spring Dynamic Modules&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The domain classes in the sample application are deployed as an OSGi module using Equinox and Spring DM frameworks. The following table shows the module packaging details for the sample application.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Table 5. Packaging and Deployment Details&lt;/span&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;1&quot; cellspacing=&quot;0&quot; style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Layer&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Deployment Artifact Name&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Module Contents&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;th&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Spring Configuration File(s)&lt;/span&gt;&lt;/small&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Client/Controller&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;loanapp-controller.jar&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Controller, Client Delegate classes&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;LoanAppContext-Controller.xml&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Facade&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;loanapp-service.jar&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Facade (Remote) Service, Server Delegate classes, XSD&#39;s&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;LoanAppContext-RemoteServices.xml&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;loanapp-domain.jar&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain classes, DAO, Common DTO&#39;s&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;LoanAppContext-Domain.xml, LoanAppContext-Persistence.xml&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Framework&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;loanapp-framework.jar&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Framework, Utility, Monitoring (JMX) classes, Aspects&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;td style=&quot;font-size: small;&quot; valign=&quot;top&quot;&gt;&lt;small&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;LoanAppContext-Framework.xml, LoanAppContext-Monitoring.xml, LoanApp-Aspects.xml&lt;/span&gt;&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 13px; line-height: 16px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; color: black; font-size: 19px; font: normal normal bold 1em/normal arial; letter-spacing: -1px; line-height: 16px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 0px; padding-right: 160px; padding-top: 4px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; color: black; font-size: 19px; font: normal normal bold 1em/normal arial; letter-spacing: -1px; line-height: 16px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 0px; padding-right: 160px; padding-top: 4px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Conclusion&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;DDD is a powerful concept that will change the way modelers, architects, developers, and testers will look at the software once the team is trained in DDD and start to apply &quot;domain first and infrastructure second&quot; philosophy. As different stakeholders (from IT and business units) with different backgrounds and areas of expertise are involved in the domain modeling, design and implementation effort, to quote Eric Evans, &quot;it&#39;s important not to blur the lines between the philosophy of design (DDD) and the technical tool box that helps us fulfill it (OOP, DI, and AOP)&quot;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 16px; font-weight: bold; letter-spacing: -1px;&quot;&gt;Advancing Frontiers&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;This section covers some of the emerging approaches that impact the DDD design and development. Some of these concepts are still evolving and it will be interesting to see how they will affect DDD.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Architecture rules and Design by Contract enforcement plays an important role in the governance and policy enforcement of domain model standards and implementation best practices. Ramnivas&amp;nbsp;&lt;a href=&quot;http://www.thespringexperience.com/show_session_view.jsp?presentationId=9239&amp;amp;showId=147&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;talked&lt;/a&gt;&amp;nbsp;about using the Aspects to enforce the rule of creating a Repository object only through Factories; this is an easy to violate design rule in domain layer.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Domain Specific Languages (DSL) and Business Natural Languages (BNL) are gaining more attention in the recent years. One can use these languages to represent business logic in the domain classes. BNL&#39;s are powerful in the sense that they can be used to capture business specifications, documenting the business rules, and as executable code as well. They can also be used to create test cases to verify the system works as expected.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;a href=&quot;http://behaviour-driven.org/&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Behavior Driven Development&lt;/a&gt;&amp;nbsp;(BDD) is another interesting concept that has been discussed lately. BDD helps focus development on the delivery of prioritized, verifiable business value by providing a common vocabulary (Ubiquitous Language) that spans the divide between Business and Technology. By using terminology focused on the behavioral aspects of the system rather than testing, BDD attempts to help direct developers towards a focus on the real value to be found in TDD at its most successful. If practiced correctly, BDD can be a great complement to DDD where the development of domain objects is positively influenced by BDD concepts; after all domain objects are supposed to encapsulate state and behavior.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Event_Driven_Architecture&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Event Driven Architecture&lt;/a&gt;&amp;nbsp;(EDA) is another area that could play a role in domain driven design. For example, an event model to notify of any state change in the domain object instance would help in handling the post-event processing tasks that need to be triggered when the state of a domain object changes. EDA helps in encapsulating the event based logic from getting embedded in core domain logic. Martin Fowler documented about&amp;nbsp;&lt;a href=&quot;http://www.martinfowler.com/eaaDev/DomainEvent.html&quot; style=&quot;color: #0b59b2; text-decoration: underline;&quot;&gt;Domain Event&lt;/a&gt;&amp;nbsp;design pattern.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 13px; line-height: 16px; text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;[source]: From &lt;a href=&quot;http://www.infoq.com/articles/ddd-in-practice&quot;&gt;InfoQ&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://e-softlearning.blogspot.com/feeds/4818663576175170402/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://e-softlearning.blogspot.com/2011/07/domain-driven-design-and-development-in.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5360527572884639261/posts/default/4818663576175170402'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5360527572884639261/posts/default/4818663576175170402'/><link rel='alternate' type='text/html' href='http://e-softlearning.blogspot.com/2011/07/domain-driven-design-and-development-in.html' title='Domain Driven Design and Development In Practice'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04613185459873469938</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgv45D4OAYGhcjgg9Vsd2oTTch6VxP-CbJE28VvybCeuWDid9XjDp1P8C_5pLKjpfCpavJ3oJHd3CFP920n7QHo9ccDCDvB9mStH9kKjOtkV34wCODTAv1vOMH46oXYUgBj25_4ZnDDdhPP/s72-c/DDDImplementationCycleDiagram_lg.gif" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5360527572884639261.post-6179513908553843588</id><published>2011-07-26T12:41:00.000+02:00</published><updated>2011-07-26T12:41:25.802+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cqrs"/><title type='text'>The denormalizer in CQRS</title><content type='html'>&lt;div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;strong&gt;The “denormalizer” is a component responsible for mapping data from the domain model to a&amp;nbsp;&lt;/strong&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Denormalization&quot; style=&quot;color: #d70606; text-decoration: underline;&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;denormalized&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;strong&gt;&amp;nbsp;table structure at the query side (an over can be found&amp;nbsp;&lt;a href=&quot;http://blog.fossmo.net/post/Update-to-the-CQRS-figure.aspx&quot; style=&quot;color: #d70606; text-decoration: underline;&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;).&amp;nbsp;&lt;/strong&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Usually the denormalizer component runs as a windows service at the server hosting the query side. Its only responsibility is to move data from the command side to the query side, and function as a router for messages from the write side. You might not want the same data on all the read servers.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;Database tables matching view models&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;On the query side, all the tables match a view model in the GUI. Yes, this means you will end up with some duplicated data in the database tables, but that’s ok. Hard disk space is cheap.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;Let’s look on how the denormalizer fits into the architecture.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-bottom: 0.5em; margin-left: auto; margin-right: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpImvaP5Cn1Rm6KTnYHX7eEyNyZsTSNIIaJHMozw90n9vlZ3vDXlr9ThHpckHina3H-gLLcA8kH1BUuQXcchwN8QbsAZcrS7GeluEu-_2paftAoYylxF0PVj_dAH-xLkgAMK18DpBz7bCX/s1600/image+%25281%2529.axd&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpImvaP5Cn1Rm6KTnYHX7eEyNyZsTSNIIaJHMozw90n9vlZ3vDXlr9ThHpckHina3H-gLLcA8kH1BUuQXcchwN8QbsAZcrS7GeluEu-_2paftAoYylxF0PVj_dAH-xLkgAMK18DpBz7bCX/s1600/image+%25281%2529.axd&quot; style=&quot;cursor: move;&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 13px; padding-top: 4px; text-align: center;&quot;&gt;&lt;u&gt;Denormalizer architecture&lt;/u&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial, Verdana, sans-serif; font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;When the domain model have done its stuff, an event is raised and a message is sent through a “pipeline” to the denormalizer on the query side. The “pipeline” can be a queue or something else that is fit to move the message in a safe way.&amp;nbsp;&lt;strong&gt;I have used NServicebus with a lot of success, but there are other ESBs or other ways to do this.&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;&lt;strong&gt;&lt;br /&gt;
&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: large;&quot;&gt;Easy programming model&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;When the denormalizer receives the message, it spreads the data into the tables that needs to be updated .&amp;nbsp;&lt;strong&gt;The tables have a one-to-one relationship with the view models.&lt;/strong&gt;&amp;nbsp;A GUI view can have multiple view models. What this gives you is a very easy programming model on the query side. All you have to think about concerning the denormalizer, is to insert/update the data to the correct tables. From the client, you look at the data as reporting data; meaning you can’t update or insert data on the query side.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: large;&quot;&gt;NOSQL&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;All though I’m referring to a relational database at the query side in this post, it doesn’t have to be a relational database. You can use a non relational database if you want to.&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;&lt;strong&gt;I would recommend MongoDB&lt;/strong&gt;&amp;nbsp;over a object database like DB4o, but that’s just my taste at the moment. You can even build your own key-value store because in most GUI views you will just fetch data based on an id.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: large;&quot;&gt;Summary&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;To sum it up; the denormalizer routs the messages from the command side in to the correct tables on the query side.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 14px; line-height: 20px;&quot;&gt;[source] :&amp;nbsp;&lt;/span&gt;From&amp;nbsp;&lt;a href=&quot;http://blog.fossmo.net/post/Command-and-Query-Responsibility-Segregation-(CQRS).aspx&quot;&gt;Fossmo&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://e-softlearning.blogspot.com/feeds/6179513908553843588/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://e-softlearning.blogspot.com/2011/07/denormalizer-in-cqrs.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5360527572884639261/posts/default/6179513908553843588'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5360527572884639261/posts/default/6179513908553843588'/><link rel='alternate' type='text/html' href='http://e-softlearning.blogspot.com/2011/07/denormalizer-in-cqrs.html' title='The denormalizer in CQRS'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04613185459873469938</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpImvaP5Cn1Rm6KTnYHX7eEyNyZsTSNIIaJHMozw90n9vlZ3vDXlr9ThHpckHina3H-gLLcA8kH1BUuQXcchwN8QbsAZcrS7GeluEu-_2paftAoYylxF0PVj_dAH-xLkgAMK18DpBz7bCX/s72-c/image+%25281%2529.axd" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5360527572884639261.post-2674827253719952823</id><published>2011-07-26T11:25:00.002+02:00</published><updated>2011-07-26T12:42:15.223+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><title type='text'>Why extends is evil ?</title><content type='html'>&lt;div style=&quot;line-height: 20px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Good designers write most of their code in terms of interfaces, not concrete base classes. This article describes&amp;nbsp;&lt;em&gt;why&lt;/em&gt;&amp;nbsp;designers have such odd habits, and also introduces a few interface-based programming basics.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;line-height: 20px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;Interfaces versus classes&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;line-height: 20px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;I once attended a Java user group meeting where James Gosling (Java&#39;s inventor) was the featured speaker. During the memorable Q&amp;amp;A session, someone asked him: &quot;If you could do Java over again, what would you change?&quot; &quot;I&#39;d leave out classes,&quot; he replied. After the laughter died down, he explained that the real problem wasn&#39;t classes per se, but rather implementation inheritance (the&amp;nbsp;&lt;code style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;extends&lt;/code&gt;&amp;nbsp;relationship). Interface inheritance (the&amp;nbsp;&lt;code style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;implements&amp;nbsp;&lt;/code&gt;relationship) is preferable. You should avoid implementation inheritance whenever possible.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;h4 style=&quot;font-weight: bold; line-height: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Losing flexibility&lt;/span&gt;&lt;/h4&gt;&lt;div style=&quot;line-height: 20px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Why should you avoid implementation inheritance? The first problem is that explicit use of concrete class names locks you into specific implementations, making down-the-line changes unnecessarily difficult.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 20px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;At the core of the contemporary Agile development methodologies is the concept of parallel design and development. You start programming before you fully specify the program. This technique flies in the face of traditional wisdom—that a design should be complete before programming starts—but many successful projects have proven that you can develop high-quality code more rapidly (and cost effectively) this way than with the traditional pipelined approach. At the core of parallel development, however, is the notion of flexibility. You have to write your code in such a way that you can incorporate newly discovered requirements into the existing code as painlessly as possible.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 20px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Rather than implement features you&amp;nbsp;&lt;em&gt;might&lt;/em&gt;&amp;nbsp;need, you implement only the features you&amp;nbsp;&lt;em&gt;definitely&lt;/em&gt;&amp;nbsp;need, but in a way that accommodates change. If you don&#39;t have this flexibility, parallel development simply isn&#39;t possible.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 20px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Programming to interfaces is at the core of flexible structure. To see why, let&#39;s look at what happens when you don&#39;t use them. Consider the following code:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div id=&quot;codewrap&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #f1f2f3; background-image: initial; background-origin: initial; border-bottom-color: rgb(102, 102, 102); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(102, 102, 102); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(102, 102, 102); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(102, 102, 102); border-top-style: solid; border-top-width: 1px; font-family: Arial, Helvetica, sans-serif; font-size: 12px; height: auto; line-height: 20px; margin-bottom: 25px; margin-left: 0px; margin-right: 0px; margin-top: -3px; overflow-x: auto; overflow-y: auto; padding-bottom: 8px; padding-left: 8px; padding-right: 8px; padding-top: 8px; width: auto;&quot;&gt;&lt;div id=&quot;codewrap18&quot;&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;f()
{   LinkedList list = new LinkedList();
    &lt;em&gt;//...&lt;/em&gt;
    g( list );
}
g( LinkedList list )
{
    list.add( ... );
    g2( list )
}
&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 20px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Now suppose a new requirement for fast lookup has emerged, so the&amp;nbsp;&lt;code style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;LinkedList&lt;/code&gt;&amp;nbsp;isn&#39;t working out. You need to replace it with a&amp;nbsp;&lt;code style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;HashSet&lt;/code&gt;. In the existing code, that change is not localized since you must modify not only&amp;nbsp;&lt;code style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;f()&lt;/code&gt;&amp;nbsp;but also&amp;nbsp;&lt;code style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;g()&lt;/code&gt;&amp;nbsp;(which takes a&amp;nbsp;&lt;code style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;LinkedList&lt;/code&gt;&amp;nbsp;argument), and anything&amp;nbsp;&lt;code style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;g()&lt;/code&gt;&amp;nbsp;passes the list to.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 20px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Rewriting the code like this:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div id=&quot;codewrap&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #f1f2f3; background-image: initial; background-origin: initial; border-bottom-color: rgb(102, 102, 102); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(102, 102, 102); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(102, 102, 102); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(102, 102, 102); border-top-style: solid; border-top-width: 1px; font-family: Arial, Helvetica, sans-serif; font-size: 12px; height: auto; line-height: 20px; margin-bottom: 25px; margin-left: 0px; margin-right: 0px; margin-top: -3px; overflow-x: auto; overflow-y: auto; padding-bottom: 8px; padding-left: 8px; padding-right: 8px; padding-top: 8px; width: auto;&quot;&gt;&lt;div id=&quot;codewrap30&quot;&gt;&lt;pre style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;f()
{   Collection list = new LinkedList();
    &lt;em&gt;//...&lt;/em&gt;
    g( list );
}
g( Collection list )
{
    list.add( ... );
    g2( list )
}
&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 20px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;makes it possible to change the linked list to a hash table simply by replacing the&amp;nbsp;&lt;code style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;new LinkedList()&lt;/code&gt;&amp;nbsp;with a&amp;nbsp;&lt;code style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;new HashSet()&lt;/code&gt;. That&#39;s it. No other changes are necessary.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 14px; line-height: 20px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;[source] : From &lt;a href=&quot;http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html&quot;&gt;JavaWorld&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://e-softlearning.blogspot.com/feeds/2674827253719952823/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://e-softlearning.blogspot.com/2011/07/why-extends-is-evil.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5360527572884639261/posts/default/2674827253719952823'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5360527572884639261/posts/default/2674827253719952823'/><link rel='alternate' type='text/html' href='http://e-softlearning.blogspot.com/2011/07/why-extends-is-evil.html' title='Why extends is evil ?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04613185459873469938</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5360527572884639261.post-1401482769261390993</id><published>2011-07-25T17:35:00.013+02:00</published><updated>2011-07-26T16:07:02.862+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cqrs"/><category scheme="http://www.blogger.com/atom/ns#" term="design pattern"/><title type='text'>CQRS architecture</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&amp;nbsp; &amp;nbsp; A graphical overview of the architecture is shown in the figure below. Lets do a quick walkthrough of the figure. A user opens an application and the first screen is loaded. The data is fetched from the &lt;i&gt;Query side&lt;/i&gt;. In this example it goes through a WCF service and uses, lets say&amp;nbsp;&lt;a href=&quot;https://www.hibernate.org/&quot; style=&quot;color: #d70606; text-decoration: underline;&quot; target=&quot;_blank&quot;&gt;NHibernate&lt;/a&gt;, to read data from the database and into a&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Data_transfer_object&quot; style=&quot;color: #d70606; text-decoration: underline;&quot; target=&quot;_blank&quot;&gt;DTO&lt;/a&gt;&amp;nbsp;that returns the data to the GUI.&amp;nbsp;&lt;em&gt;The&amp;nbsp;&lt;/em&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Data_transfer_object&quot; style=&quot;color: #d70606; text-decoration: underline;&quot; target=&quot;_blank&quot;&gt;&lt;em&gt;DTO&lt;/em&gt;&lt;/a&gt;&lt;em&gt;&amp;nbsp;is tailored to fit the screen the user is viewing.&lt;/em&gt;&amp;nbsp;The query database is often&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Denormalization&quot; style=&quot;color: #d70606; text-decoration: underline;&quot; target=&quot;_blank&quot;&gt;de-normalized&lt;/a&gt;to improve reading. The user may brows through different screens, and the process is the same. A&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Data_transfer_object&quot; style=&quot;color: #d70606; text-decoration: underline;&quot; target=&quot;_blank&quot;&gt;DTO&lt;/a&gt;&amp;nbsp;tailored for the users screen is returned from the database. Eventually, the user wants to change the data in one of the screens. What then happens is that a command message is created based on the data that have changed in the view and sent down the left side of the figure; the command side.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The &lt;i&gt;command message&lt;/i&gt; is sent into the domain model to get validated against the business rules. A error message is sent back to the client if some of the business rules fails (how this is done can differ). If the message goes through the domain model without errors, it’s persisted to the write database and synchronized with the read database(s).&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The &lt;i&gt;read databases&lt;/i&gt; then will pick up the new messages from the queue or bus, and update itself. The &lt;i&gt;synchronization&lt;/i&gt; arrow in the figure it is used to initialize the read databases based on the write database.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;The &lt;i&gt;command side&lt;/i&gt; should never return other data than the error message. If you follow this rule, the command side will only be behavioral. This makes logging of what happens in the domain model very easy, and it’s quite easy to track what the user wanted to do, not only what the result of his actions were. The approach I’m describing in this post is a bit different than Greg Young describes. His solution promotes no database on the command side; a database is only needed for reporting. This is a great approach, but it makes things a bit more complex and it requires a green field project(?). The approach I’m describing can be used with a brown field application without much change to the existing architecture. In most cases you only have to add a query-side to the “old” architecture.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfDrrDSt9wSuEAnaLHYovItprcyxOksaeFFrq1Hw-vSmDWnQxoz5Br-nrxIbOtq8hYcB8VNM3EbaeNirOqhTAa320tbEDCKmxRpCyMm9b-oApwNSu6VJ0Yn5Vm00csckacwdA_2sHX0j_7/s1600/image+%25282%2529.axd&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfDrrDSt9wSuEAnaLHYovItprcyxOksaeFFrq1Hw-vSmDWnQxoz5Br-nrxIbOtq8hYcB8VNM3EbaeNirOqhTAa320tbEDCKmxRpCyMm9b-oApwNSu6VJ0Yn5Vm00csckacwdA_2sHX0j_7/s1600/image+%25282%2529.axd&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: large;&quot;&gt;Why add query side DTOs?&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; text-align: justify;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;In a traditional domain model, you will create the objects for solving domain logic, not for viewing. They have behavior rather than shape. To make domain objects more viewable, many developers use mapping between the domain model and a DTOs tailored for being displayed. This results in a lot of mapping between objects for the developer and domain models who exposes getters and setters (To learn why this is bad, do a Google search on; getters and setters are evil).&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; text-align: justify;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;If you are using a ORM like NHibernate, you have to add getters to the domain model (and make the properties and methods virtual if you want to use lazy loading), and I think this is ok. The model is still protected against unwanted changes that can make it invalid. Every change have to happen through its command methods.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: large;&quot;&gt;Summary&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 90%/normal Arial, Verdana, sans-serif; letter-spacing: 0px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;What you get from this architecture is; scalability on the read side of the application (where you normally get most load), the possibility to log all happenings in the domain model (by tracking the commands and events in the domain model), and a domain model that only have to worry about writing data, not be a transporter of data from the database to the GUI. I guarantee that this alone will make things a lot easier for you. And one final thing; creating objects (DTOs) based on the view helps us avoid a lot of mapping and a lot of requests against the database to fill the view with data. I will go through the parts of the architecture in more details in future posts.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 14px; line-height: 20px;&quot;&gt;[source] :&amp;nbsp;&lt;/span&gt;From &lt;a href=&quot;http://blog.fossmo.net/post/Command-and-Query-Responsibility-Segregation-(CQRS).aspx&quot;&gt;Fossmo&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://e-softlearning.blogspot.com/feeds/1401482769261390993/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://e-softlearning.blogspot.com/2011/07/cqrs-architecture.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5360527572884639261/posts/default/1401482769261390993'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5360527572884639261/posts/default/1401482769261390993'/><link rel='alternate' type='text/html' href='http://e-softlearning.blogspot.com/2011/07/cqrs-architecture.html' title='CQRS architecture'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04613185459873469938</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfDrrDSt9wSuEAnaLHYovItprcyxOksaeFFrq1Hw-vSmDWnQxoz5Br-nrxIbOtq8hYcB8VNM3EbaeNirOqhTAa320tbEDCKmxRpCyMm9b-oApwNSu6VJ0Yn5Vm00csckacwdA_2sHX0j_7/s72-c/image+%25282%2529.axd" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5360527572884639261.post-4865270278425090477</id><published>2011-07-19T10:54:00.019+02:00</published><updated>2011-07-26T16:07:23.437+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="design pattern"/><category scheme="http://www.blogger.com/atom/ns#" term="gwt"/><category scheme="http://www.blogger.com/atom/ns#" term="mvp"/><title type='text'>Model-View-Presenter Architecture With GWT</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 19px;&quot;&gt;&lt;b&gt;Model-view-presenter&lt;/b&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 19px;&quot;&gt;&amp;nbsp;is a a derivative of the&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 19px;&quot;&gt;&lt;a class=&quot;mw-redirect&quot; href=&quot;http://en.wikipedia.org/wiki/Model-view-controller&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; color: #0645ad; text-decoration: none;&quot; title=&quot;Model-view-controller&quot;&gt;model-view-controller&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 19px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 19px;&quot;&gt;&lt;a class=&quot;mw-redirect&quot; href=&quot;http://en.wikipedia.org/wiki/Software_pattern&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; color: #0645ad; text-decoration: none;&quot; title=&quot;Software pattern&quot;&gt;software pattern&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 19px;&quot;&gt;, also used mostly for building&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 19px;&quot;&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/User_interface&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; color: #0645ad; text-decoration: none;&quot; title=&quot;User interface&quot;&gt;user interfaces&lt;/a&gt;[Wikipedia]&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 19px;&quot;&gt;. So&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 17px;&quot;&gt;Building an MVP-based application can be straightforward and easy once you understand the fundamentals behind this design pattern.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; line-height: 19px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;line-height: 1.5em; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.4em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; line-height: 19px;&quot;&gt;In MVP the&amp;nbsp;&lt;i&gt;Presenter&lt;/i&gt;&amp;nbsp;assumes the functionality of the &quot;middle-man or the boss&quot; (played by the Controller in MVC). Additionally, the&amp;nbsp;&lt;i&gt;View&lt;/i&gt;&amp;nbsp;is responsible for handling the UI events (like mouseDown, keyDown, etc), which used to be the Controller&#39;s job. Eventually, the&amp;nbsp;&lt;i&gt;Model&lt;/i&gt;&amp;nbsp;becomes strictly a&amp;nbsp;&lt;a class=&quot;mw-redirect&quot; href=&quot;http://en.wikipedia.org/wiki/Domain_Model&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: #0645ad; text-decoration: none;&quot; title=&quot;Domain Model&quot;&gt;Domain Model&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.4em;&quot;&gt;&lt;div style=&quot;line-height: 1.5em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; line-height: 19px;&quot;&gt;The following post resumes the GWT-MVP pattern interaction and provides an helpful diagram.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 1.5em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; line-height: 19px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; line-height: 1.5em; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbS8Ar0OCy7DfM5yWOSZBRX4m0YSXk94RZwiLNrt6CP0JV8KBxF6EkwYdwMKHMbg_VPd3i3RFyRTpEFXgHyOk3aj9lsTICP59kvbbVrEy4c3n5Mex4fdwVyNMoSREsY3raM8-JNFX3KpbC/s1600/wxd.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbS8Ar0OCy7DfM5yWOSZBRX4m0YSXk94RZwiLNrt6CP0JV8KBxF6EkwYdwMKHMbg_VPd3i3RFyRTpEFXgHyOk3aj9lsTICP59kvbbVrEy4c3n5Mex4fdwVyNMoSREsY3raM8-JNFX3KpbC/s1600/wxd.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; line-height: 1.5em; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 1.5em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; line-height: 19px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;div style=&quot;line-height: 1.5em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; font-size: 14px; line-height: 20px;&quot;&gt;[source] :&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; line-height: 19px;&quot;&gt;From &lt;a href=&quot;http://www.nieleyde.org/SkywayBlog/post.htm?postid=37782056-c4e1-4dfb-9caa-40ab9552ca3b&quot;&gt;Niel&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://e-softlearning.blogspot.com/feeds/4865270278425090477/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://e-softlearning.blogspot.com/2011/07/solamenteniel-gwt-model-view-presenter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5360527572884639261/posts/default/4865270278425090477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5360527572884639261/posts/default/4865270278425090477'/><link rel='alternate' type='text/html' href='http://e-softlearning.blogspot.com/2011/07/solamenteniel-gwt-model-view-presenter.html' title='Model-View-Presenter Architecture With GWT'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04613185459873469938</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbS8Ar0OCy7DfM5yWOSZBRX4m0YSXk94RZwiLNrt6CP0JV8KBxF6EkwYdwMKHMbg_VPd3i3RFyRTpEFXgHyOk3aj9lsTICP59kvbbVrEy4c3n5Mex4fdwVyNMoSREsY3raM8-JNFX3KpbC/s72-c/wxd.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>