New-age Transactional Systems - Not Your Grandpa's OLTP
John Hugg discusses high volume transaction processing applications with high and low frequency profiles, and how VoltDB can be used for that purpose.
The content has been bookmarked!
There was an error bookmarking this content! Please retry.
Posted by Jonathan Allen on Feb 22, 2007
In a new case study published by Domain Language, Inc., Ying Hu and Sam Peng show how they solved some major problems dealing with international currency by selectively applying Domain-Driven Design to their existing application.
The first thing Hu and Peng did was create Currency and Money classes. The first wraps a string and ensures said string is actually a valid currency. The second merges a currency with the amount of that currency.
Pretty typical stuff, but what makes this study interesting is how they thread the new class into their existing code. In one example they only change the external interface, within the class they still use a string and decimal to store the values.
But wait a second, the legacy settlementAmount and settlementCurrency still exist inside Order as private members. Isn’t it better to replace them with Money too? Yes, ideally, all private members should be replaced too. They are still there because of the shortage of time: due to the massive usage of primitive types, we found it impractical to exhaustively replace every occurrence. As a compromise, we decided to refactor important interfaces first. This way, even though many of the ugly bits are still around, they are hidden within a well defined boundary.
No case study would be complete without mentioning some of the problems they ran into. The first issue they come across is feature creep within a class.
This is only the start. These value objects are now widely used in the system. But because of their prominent expressive power, developers start to put stuff in just because of convenience. Consider the following method defined inside Rate class:
This method adds the “moneyToAdd” to the “target” and makes sure the resulting Money object is expressed in the target Money object’s Currency. Whoever put it in probably wanted to encapsulate the conversion between two Money objects, and perhaps some form of this function would have made sense there. However, adding money certainly is not Rate’s responsibility, and so this new function weakened Rate’s representation of the rate concept and at the same time subtly coupled it to a higher layer of the system that adds Money for a particular reason.
Another issue we deal with is the unclear message sent by the fact that a fair amount of
legacy primitive types still stick around side-by-side with their value object counterparts.
Instead of refactoring, some developers continue using them. They have even added
operator overloading to convert value objects back to primitive types!
Hu and Peng conclude on a positive note.
And yet, in spite of all the incompleteness and imperfection of our ongoing development work, these "domain fundamentals" have raised our level of abstraction above the level of decimals and strings, and have been one of the keys to allowing our system to continue to develop and produce rich applications. Our domain model is evolving, and so is our domain- driven design journey.
Do you have your own stories about introducing Domain-Driven Design into an existing project? Let us know.
Monitor your Production Java App - includes JMX! Low Overhead - Free download
18 agile and lean practices for effective software development governance
Using Drools? See what you're missing! Get the Power of Drools with the Assurance of Red Hat
Improve Java Garbage Collection, Runtime Execution, and JVM visibility with Zing
In today’s hyper-competitive world, later may be too late to adopt Agile development and this Roadmap for Success will help you get started. Download "Agile Development: A Manager's Roadmap for Success" now!
John Hugg discusses high volume transaction processing applications with high and low frequency profiles, and how VoltDB can be used for that purpose.
Kevlin Henney examines code samples to see what can be learned from them starting from the premise that one won’t write great code unless he knows how to read it.
Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.
Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).
Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.
Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.
One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.
InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.
No comments
Watch Thread Reply