Chapter 9. Extract Domain Logic to Transactions
In the previous chapter, we extracted all our SQL statements to a layer of Gateway objects. This encapsulates the interactions between the application and the database.
However, we usually need to apply some amount of business or domain logic to the data coming from and going back to the database. The logic can include things like data validation, adding or modifying values for presentation or calculation purposes, collecting simpler records into more complex ones, using the data to perform related actions, and so on. This domain logic is often embedded into a page script, making that logic difficult to reuse and test.
This chapter describes one way to extract domain behaviors into a separate layer. ...
Get Modernizing Legacy Applications in PHP now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.