I recently “took offence(Joe Walnes’ Blog – Inversion of Control and Dependency Injector Pattern)”:http://joe.truemesh.com/blog//000162.html at the fact that Martin Fowler has decided that the well known phrase Inversion Of Control was no longer suitable, and instead decided to rename it “Dependency Injector(Inversion of Control Containers and the Dependency Injection pattern)”:http://martinfowler.com/articles/injection.html. Among my reasons for this annoying me (beyond the fact that even this new term isn’t completely correct) was the fact that in many ways renaming such a well known pattern can make discussion of the pattern a problem – one person talks about IoC, the other about Dependency Injector, another talks about the Dependency Inversion Principle and so on. Martin’s trait of doing this is evident in his otherwise excellent “Patterns of Enterprise Application Architecture”:http://www.amazon.co.uk/exec/obidos/ASIN/0321127420/qid=1074517170/sr=1-2/ref=sr_1_11_2/026-5708252-6942053. The ludicrously well known “Data Access Object(Core J2EE Patterns – Data Access Object)”:http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html is nowhere to be found – it was only via a google search that it became clear that “Gateway” was what I’m after.
The Gateway pattern as outlined is actually far more of an abstract pattern, and not a direct replacement for the DAO pattern. Gateway needs to be combined with the Data Transfer Object pattern (sorry, Value Object) to produce a true DAO pattern. Gateway as it stands is a pattern used to provide a simple interface to some complex code, which is otherwise external to your application code – it’s really one of those no brainier patterns, most of us for example wrap third-party API’s with our own code.
Redefining otherwise confusing terms as something easier to understand is all well and good, but there comes a time when renaming even a confusing term (and DAO for me does exactly what it says on the tin) becomes counter-productive due to the widespread knowledge of the way its defined now. The windows UI for example contains many inconsistencies that make learning it more awkward than other UI’s, however MS are not going to start changing it now – they have millions of users worldwide who know how it works right now. Perhaps people should start employing a more pragmatic view before they start renaming things all over the place.
I throughly recommend you read Martins book though, its certainly the best treatment of the subject of Enterprise patterns I’ve seen to date, author idiosynchrocies aside. I can also recommend Sun’s online “J2EE pattern catalogue”:http://java.sun.com/blueprints/corej2eepatterns/Patterns/index.html which covers some of the same ground, albeit in less detail and as a free online resource.