Speaker Topics - No Fluff Just Stuff

Domain Driven Design and Development In Practice - Code Generation

Domain Driven Design (DDD) technique helps architects and developers in mapping business domain concepts to software artifacts. When applying DDD techniques in a Java application, there are several domain classes and other artifacts (like configuration files) in Domain, Service and Application architecture layers that can be automatically generated using Code Generation techniques. For example, in a typical web application same data flows through the application layers in different forms like Domain Object (DO), Data Transfer Object (DTO) and XML. The developers usually write these classes manually from scratch or write the first class and then copy and paste when they need the classes for other use cases. These and other classes like Facade, Data Access Object (DAO interface, implementation and the unit test classes) are good candidates for code generation.

Code generation helps the software development process by generating consistent code for the classes and other artifacts that have infrastructure (boiler-plate) logic but don't have any business logic. It fits in very well with Domain Driven Design philosophy of “Domain First, Infrastructure Second” where the developers can focus on business domain concerns and take the advantage of code generation to address the infrastructure concerns. If Domain Driven Design provides the “What”, it is the code generation, as a development technique, that can provide the “How”. Code generation is a good long-term solution even though this effort involves some initial investment (in terms of coding and time) which pays itself off in medium to large domain models.

This technical session will discuss the role of code generation in a Java web application from the Domain Driven Design and Development context. I will start off the presentation with a quick overview of the Layered Architecture in a typical web application that was developed using DDD design pattern and implemented using Spring Framework (for middleware services) and JPA (with Hibernate3) for persistence. I will talk about the code generation concept in the project, that starts with the creation of a standard and consistent project template (using Maven Archetype feature). The discussion will include a list of the classes we need to write from scratch (like XSD, Domain Object and Service) and then code generate the Java classes and configuration files in domain and other layers (like DAO's, Factories, Repositories, Delegates, DTO's, Unit Tests, and Spring configuration files).

The presentation will include a demo of the Java application to show how domain elements and artifacts can be code generated using tools like openArchitectureWare (oAW), Eclipse, Maven, and Spring. The session will conclude with the design guidelines and best practices to follow when considering code generation as part of implementing a Business Domain Model.


About Srini Penchikala

Srini Penchikala currently works as an Enterprise Architect at a major financial organization in Metropolitan Detroit area. He has over 14 years of IT experience and has been working on Java projects since 1996 and J2EE technology since 2000. His main areas of interest are Agile Enterprise and Service Oriented Architectures, Domain Driven Design & Development In Practice, Aspect-Oriented Programming (AOP), Architecture Rules Enforcement, Enterprise Integration Patterns, and light-weight middleware frameworks such as Spring and Hibernate. He has presented at conferences and Java User Groups on topics like Agile Enterprise Architectures, Architecture Governance, and Domain-Driven Design. He has published numerous articles on J2EE topics on websites like InfoQ.com, ServerSide.com, O'Reilly Java Network (ONJava), DevX Java, java.net and JavaWorld. Srini also publishes a blog on Java, JEE, and other topics at http://srinip2007.blogspot.com/. He is also a leader of Detroit Java User Group (http://sites.google.com/site/detroitjug/).

More About Srini »