Friday, April 04, 2008

Good Domain Modeling

In my experience, the topic of good domain modeling comes up, and people are often lacking resources that discuss it thoroughly. I have found three texts that have been extremely helpful in this area, and I would recommend reading them in this order:

  1. Chapter 1 of "Java Modeling in Color With UML" by Peter Coad, which can be found online at http://www.petercoad.com/download/bookpdfs/jmcuch01.pdf
  2. "Streamlined Object Modeling" by Jill Nicola, Mark Mayfield & Mike Abney (Google "Streamlined Object Modeling")
  3. "Domain Driven Design" by Eric Evans (Google "Domain Driven Design")
Coad's book "Java Modeling in Color With UML", discusses the idea of color and explicitly modeling as classes his four archetypes:
  • Description (aka "catalog-like entry"),
  • PartyPlaceThing (aka "Actor"),
  • Role (aka "representation of an actor in an event context"), and
  • MomentInterval (aka event, action, interaction, or transaction).
Since MomentIntervals represent actions, events, transactions, or interactions, they get the hottest color: pink. The remaining colors are ordered according to decreasing temperature: Roles (participating in MomentIntervals) are yellow, Actors (playing Roles) are green, and Descriptions (describing Actors) are blue.



These ideas are a good start, but you quickly find out that they are too rigid; you cannot give a class a single color, because it participates differently in different contexts. For example, consider a "subsequent role" pattern: a role class Employee may be played by an actor class Person, but a role class Manager may be played by an actor class Employee; this implies that an Employee can be either an actor or role, depending on the context. Thus, a Manager is a subsequent role of the role Employee, and a single color and archetype will not suffice.

As a result of this phenomenon, a refinement to Coad's color modeling technique is in order. Specifically, it is not the classes that need to have a color, but it is the associations between them that need to be colored. Given the example above, you quickly realize that, if you represent the association between Person & Employee as a line (like you do in UML), then the Person side of the line should be green and the Employee side of the line should be yellow.

Streamlined Object Modeling by Nicola et al, rigorously discusses domain modeling, and presents examples in Java & Squeak (Smalltalk). The book, published in 2001, is showing its age, in that rollbacks are handled directly in code, and explicit persistence handling in the domain objects is discussed and illustrated. Today, these two burdens have been lifted, thanks to execution within a transactional context and transparent persistence, so this part of the examples and discussions can be safely ignored. Also, notably absent from Streamlined Object Modeling is the discussion of placing a domain model within an enterprise context; see Eric Evans' Domain Driven Design for such a complimentary discussion.

Streamlined Object Modeling does have a web site that is fairly static (it looks like the last update was 2002), but informative at http://www.streamlinedmodeling.com.

From the above website:
Streamlined Object Modeling pares down object modeling to just the bare essentials necessary to model business domains, business rules, and business services.
  • Object think and object selection principles.
  • Twelve all-encompassing "collaboration patterns" for modeling real-world relationships.
  • Five kinds of business rules, three types of services, and six categories of properties.
  • Rigorous methods for discovering, organizing, and implementing business rules around objects.
I hope you find these useful. They have had a profound impact on the way that I approach development, and their ideas have thus far withstood the test of time.

Thursday, November 15, 2007

Mac OS X: Mouse-Follows-Focus (Not Focus-Follows-Mouse)?

More from the Windows-Power-User-to-Mac-Power-User-Adjustments department: Windows has a really nice key on the keyboard that I use a lot: the context-sensitive menu key. It looks something like this on most Windows machines:
It allows me to perform a right-click wherever focus currently is without having to use the mouse.

So, Mac OS X has its equivalent of right-clicking, which is Ctrl-Click. So far, so good, except that I still have to use the mouse. Next, I discovered that Fn-NumPad-5 (which is Fn-Option-I on my MacBook Pro, BTW) does the same thing as a Ctrl-Click, so that I can do the Mac equivalent of a keyboard-only right-click. The problem is, instead of using the current focus (which I maniuplated via various keyboard navigations), it uses the current location of the mouse pointer as the location where the Ctrl-Click is effected.

Ideally, I'd like Fn-NumPad-5 to use the current focus to effect the click instead of the current pointer position, but I'd be willing to have the mouse follow the current focus. I've seen focus-follows-mouse, but that's not what I'm trying to do here.

Anyone have any ideas?

POP woes with Yahoo Mail

I'm pretty happy with Yahoo Mail, having been a customer since the service first started, however, I'm having some problems now that I've started using POP access.

Throughout the day, I get prompted by Mail on Mac OS X to reenter the password for my two POP accounts (one for my "@yahoo.com" email address and one for my "@matthewadams.org" address). This happens probably 10 or more times per day. It also happened when I was using Microsoft Outlook 2007 on Windows XP. Oh, and yes, I am checking the "remember my password" checkbox.

Naturally, I contacted Yahoo Business Mail tech support with low expectations of their ability to diagnose and correct the problem, assuming that if I see it from both Mac OS X and Windows, chances are the problem's on their end. Needless to say, my low expectations were met and not exceeded.

Several times each day, I have to reenter my POP password, and it's getting annoying. Anyone else seeing these problems?

Thursday, November 01, 2007

Mac OS X and mp3 Files

So I've been using my new MacBook Pro for a month or so now, and this'll probably the first in what I'm sure will be a series of questions as I transition from being a power Windows navigator to the same on Mac OS X.

I'd like to copy iTunes playlists, consisting only of mp3 files, to my various, generic, USB mp3 players. When I plug the player in, it doesn't show up in iTunes. Please don't tell me that my only option is to find the mp3 files on disk and copy them using Finder (or PathFinder)!

Wednesday, October 31, 2007

JPOX Is Better Than Hibernate?

Oh, yeah, the whole reason I started back into the blogosphere: I saw a post over on the JPOX forum that I thought was worth sharing, just for the stir-the-pot factor. It's entitled "JPOX better than Hibernate according to Hibernate trainer!"

NB: JPOX is a JDO- and JPA-compliant ORM, and is the reference implementation for JDO 2.0.

In all fairness to Hibernate, clearly the most widely used ORM in the marketplace, it wasn't a trainer from Red Hat/JBoss/Hibernate; it was actually a Spring Framework trainer (no, not me, to my knowledge) who mentioned it. Perhaps the poster, Chris Colman, could expound a bit more on why. It looks like he's from Step Ahead Software and exPOJO, and does a fair amount of JDO and Hibernate work.

Catching up

I'm going to take a moment in this post to catch up, since it's been a while since I posted anything. Let's see, my last post (other than to say that I'm moving to this new blog), had to do with persistence within an SOA.


While I still absolutely love what Xcalia has been able to do with transparent persistence (namely, move beyond relational databases and allow you to use literally anything that you can connect to or call upon from Java as a data source), I was given an opportunity to go to work for Interface21, the people behind the Spring Framework.

So far, it's been a great experience. I'm a senior consultant now, primarily doing training (which I enjoy very much), consulting, and some technical marketing. I tried to keep my Interface21 profile page interesting; you can judge for yourself.

I'm still serving on the JDO and JPA expert groups, but not the SDO expert group anymore. Hopefully soon, those of inclined to do so will begin blogging about enhancements in JPA 2.0, and I'll probably do that on the Interface21 team blog. As has been the case for years, the JDO 2.0 and 2.1 work has been progressing nicely over at Apache JDO.

Well, that'll do it for now, and I hope to post a bit more regularly now. We'll see if I actually do...

Goodbye JRoller, Hello Blogger.

Not that very many people read it, but I've decided to move my former blog to Blogger and my own domain (matthewadams.org). We'll see how it goes using Blogger!