For an example of embedded action logic mixed with dependency logic, we can look at the ending example code from the last chapter in Appendix G, Code after Response View File. Therein, we do a little setup work, then we check some conditions and call different parts of our domain Transactions
, and at the end we put together a Response
object to send our response to the client.
As was the problem with mixed-in presentation logic, we cannot test the action logic separately from rest of the page script. Similarly, we cannot easily change the dependency creation logic to make the page script more testable.
We solve the problem of embedded action logic as we did with embedded presentation logic. We must extract the action code to a class of its own to separate the various remaining concerns of our page script. This will also allow us to test the action logic independently from the rest of the application.