I've figured I need to get rolling on the example/reference case for the Action Domain Object-talk.
After some long and hard pondering I drifted away from the insurance domain and into something far more web 2'ish: an online community site.
I'm gonna call it The Universe. It's pretty simple, facebook'ish application that includes Worlds, Groups, Rooms and People.
- The Universe can crud (save, browse and delete) Worlds
- A World can crud Groups , Rooms and People
- A Group/Room can add/remove People (members)
- (or a Person can join/part Rooms and Groups)
- A Person can send messages to People or Rooms
- A Room is like a chat-room, as opposed to Group which is a more permanent organization of People
It does have some complexing features, like a bunch of many-to-many relations, and plenty of alternative ways to implement the domain model, i.e. which entity is responsible for sending messages, manage People, etc.
Now, this wouldn't be any fun to implement without some restricting rules making it hard for me:
No Services and DAOs, only (a few) aspects/interceptors.
It will be implemented in Java.
Only one file/class per entity.
Operations should be RESTable.
They should be executable from a console application.
No XML (!).
So, then I started thinking about some URLs. Thinking URLs are a great way of getting an elegant web application. You get re-usable action chunks (cause you start thinking of atomial simple operations) and pretty URLs.
Let's trigger some operations:
Behold, The Universe:
/universe/browseCreate a World in the Universe:
/universe/worlds/create?name=earthNext, create a Group in The newly created World:
/universe/worlds/earth/groups/create?name=developersCreate a person:
Oh, I just discovered I need a couple of other entities to represent relations between People, Groups and Rooms. I'll use memberships for Groups and visits for Rooms.
Add me to the developer group (I'll skip the /universe/worlds/earth/ from this point):
.../memberships/create?member=ferris&group=developersLater on, I log in:
.../members/ferris/login?password=postitAnd join the chat-room "hackers":
.../visits/create?visitor=ferris&room=hackersSend a message to the hackers-room, oh copy to John by the way:
Right, think the idea is starting to come through. Now it's getting a bit late so I'll think I'll have to leave it like that. These URLs are very much subject to change, and if anyone can see any pitfalls I'm running in to, please comment.
Next week I'm gonna figure out whether I'm gonna make this happen with Grails or Struts2, or some other technology.
The following have been the inspirations to this post:
- Any article I ever read on DDD, REST and CRUD
- Ted Husted's RestfulActionMapper
- I was listening to this video while writing, and it's quite annoying that David has thought of everything I want to do, only in Rails (by way of Johannes, thanks)