POJOs in Action

Book Excerpt by Chris Richardson

The Domain Model pattern is an excellent way to organize complex business logic. However, in some situations you may not want to use a domain model, such as when the development team lacks the necessary OO design skills to develop a model, or the business logic is very simple. It also does not make sense to use a domain model when you cannot use a persistence framework because, for example, the architecture does not include one or the application accesses the database in ways that require it to use SQL directly. In these situations, you should consider writing procedural business logic, an approach also known as the Transaction Script pattern.

In this chapter, we explore the benefits and drawbacks of using the Transaction Script pattern, and describe how to implement this pattern using POJOs and the Spring framework. You�ll learn how to implement the procedural business logic and database access logic in a way that makes them easier to develop, test, and maintain. You�ll also learn how to develop procedural business logic using a test-driven approach that uses mock objects to implement the tests.

This book excerpt is from POJOs in Action by Chris Richardson (ISBN 1932394583), published by Manning Publications Co., copyright 2006.

  • Download Chapter 9, Using the Transaction Script pattern (PDF, 900Kb).

Chris Richardson is a developer and architect with over 20 years of experience. He is the author of POJOs in Action, which describes how to build enterprise Java applications with POJOs and lightweight frameworks such as Spring and Hibernate.