For those of you who know noticed my blog silence last week or my extensively delayed responses on emails, it was because I was down in Florida doing some consulting work with Clark Valberg and Hal Helms. The days were long and productive, but unfortunately, left me very little time to check my email or read up on CF Bloggers. While down there, I got to spend a good deal of time with Hal Helms, who, until recently I had only known through community elements such as "Helms and Peters Out Loud" and his Occasional Newsletter. Hal Helms is insanely smart, so I tried to take advantage of the time by asking him all sorts of questions about Object Oriented Programming.
For months, I have been trying to break into the Object Oriented Programming (OOP) world; while I feel that I have come a long way, it is obvious that there are some huge mental barriers through which I've not been able to break. Hal helped break one of those babies down. During a conversation with Hal, he dropped a pretty awesome nugget of information in my lap - he stated that Domain Models are supposed to be "Idealized" versions of real word constructs. I was not familiar with the concept of "Idealized Objects", but basically what it means is that our domain models have behaviors that don't necessarily reflect what their real-word equivalents would have, but do reflect the behaviors that we sort of wish they had (if we lived in an ideal world).
As an example, we explored the idea of Dollar Bills that travel around the country. I am sure that most people have come across a Where's George dollar whose journey you can track online. I brought this up because to me, dollar bills are not intelligent objects; if I were to have a Domain Object that modelled the dollar bill in the Where's George system, my instinct would be to just have getter and setting methods for things like serial number and date printed. If I wanted to get an array or query of locations at which the bill had been tracked, I would have passed the dollar bill instance off to some DollarBillService that had a method like GetDollarLocations().
The problem with this, as Hal Helms pointed out, was that we are not getting any of the benefits of object oriented programming. By only having simple property getters and setters on the dollar bill object, we have nothing more than a bloated struct. Now, I've heard the whole speech about "anemic domain models" before and it never really affected me, but Hal also said, and here's where he really hit a chord, the dollar bill shouldn't be a dumb object as it is in the real world - it should be an "idealized" object; meaning, it should know about and be able to report on where it has been. As such, the idealized dollar bill itself would have a method like DollarBill.GetLocations() that would return an array or query of locations (most likely an array of "Location Objects").
I think the concept of Idealized objects is going to make things easier for me. For the longest time, I think I was so hung up on modelling the real world that I ended up creating object-oriented procedural code, which, as some of you probably know, has all the overhead of OOP and none of the benefits. I still have a long journey ahead of me, but I think Hal definitely got me a lot closer with the personification and idealization of objects. Thanks Hal!
While down there, I also got to sit in on an awesome pod cast in which Clark Valberg and Hal Helms discussed the design of beautiful things. Definitely an interesting conversation. But more on that to come, I am sure.