Bindings, Platforms, and Innovation
This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.
Tracking change and innovation in the enterprise software development community
Posted by Jonathan Allen on Feb 22, 2007 03:20 PM
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.
Download the Free Adobe® Flex® Builder 3 Trial
Adobe® Rich Internet Application Project Portal
Download the Free Adobe® Flex® Builder 3 Trial
Effective Management of Static Analysis Vulnerabilities and Defects
This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.
This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.
This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.
This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.
This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.
After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.
IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.
Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.
No comments
Watch Thread Reply