5

I am developing a large application where the previous developer used Martin Fowlers Transaction Script pattern.

The requirements are becoming more complex and it is becoming a bit of a maintenance nightmare. Therefore I have started to use Fowlers Domain Model and Table Data Gateway in an attempt to separate concerns and reuse code. It is becoming a refactoring process.

My question is: is it bad practice to mix and match patterns? e.g. using Transaction Script and Domain Model in the same application or is this relatively common practice?

  • I won't put a full blown answer as I'm short on time, but I'll say this. Considering a 3 layered architecture, the Transaction Script and Domain Model patterns both have the same purpose in the Logic tier. In very simple terms, you use a Transaction Script when the logic is simple and a Domain Model when it is complicated. In this case, I wouldn't suggest mixing and matching. For patterns in general it's fine. – Sotirios Delimanolis May 25 '13 at 20:52
  • @Sotirios Delimanolis, thanks. Just to be clear; are you saying dont mix and match the two patterns in the same app? Can you explain why if you have time? – w0051977 May 25 '13 at 22:26
4

It is fine to mix domain logic patterns. A large system can be broken down into modules with domain logic patterns selected based on complexity of each module e.g. Complex stuff - Domain Model Pattern and simple stuff can use Transaction Script. If then you find some simple modules are beginning to become complex you can refactor to the domain model pattern. I cover this in a book I am writing at the moment https://leanpub.com/Practicing-DDD

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.