Sadek Drobi’s Blog

May 27, 2007

It is NOT a Test Driven Design

Filed under: Refactoring, Agile Programming, Domain Driven Design — Sadache @ 9:17 pm

There is no good design guaranteed with TDD, actually it is a Test Driven Development. It is a good practice for defiling contracts before starting to write code. This assures some decoupling between the contract and the implementation. But don’t close your eyes and expect it to design for you. You should be careful about not turning your code into functions just wrapped into objects. Because then it is a bit late for refactoring. Jimmy Nilsson [Applying DDD and Patterns] couples TDD with DDD to produce a good design. Because DDD is about design, and TDD is about a programming discipline, a beautiful one, but is not about design…

Transactions are not automatic! Logs neither…

Filed under: Architecture, DOTNET, Agile Programming, Domain Driven Design — Sadache @ 8:12 pm

As Aspect Oriented Programming is getting more and more known, a lot of wrong usages appear. Surprisingly, I’ve seen common agreement among J2ee/.net architects for applying it in their application architectures.

First of all, Aspects are not only about the Spring’s  code injection by interception. Even if it looks like interesting, this style of AOP use can be misapplied. One of these misapplications is in transactions. I ve heard it a lot, “All my services are transactions” or “All methods that end with service are transactions” and worse “all of this package (assembly) is transactional!”

Transactions are a part of business logic, they should be explicit in the code, and they should belong to whatever layer they need to belong to. Transactions are not automatic, and cant be applied as an aspect of a whole layer or as an architecture decision.

Yet applying them as Aspects (Aspect) Attributes or Tags is explicit, but they should not be exclusive to somewhere in the architecture, THEY ARE NOT A PART OF THE ARCHITECTURE!

I like the .Net’s implementation of TransactionScope in System.Transactions. It fits rather good to the functional meaning of transactions. I still prefer to have a more explicit code that expresses and treats them. After all, EBay is Transactionless (talking about database technical transactions) and Amazon doesn’t do any Distributed Transactions! That confirms that transactions should be treated as business  notions rather than technical.

I guess it wont be very intresting for readers if I introduce an aspect for loggin all my events and ideas to this weblog! Even if it would be much eaiser for me :) Beleive me, that would be floody!

Powered by WordPress