views:

54

answers:

2

Let's say I want to model a cinema. The cinema will have a couple of rooms(for example, 7), where the movies are being played.

I wonder how should I design the domain model for this scenario.

  • Should the Cinema class concept concept have a direct association with the 7 rooms? alt text
  • Should the Cinema class concept have an association with a catalog of the 7 rooms? alt text

Why?

I am having some trouble understanding why in some places I see the first case and in some others I see something like the second case.

If instead of rooms, I wanted to depict the relationship between Cinema and:

  1. Tickets to sell (today).
  2. Tickets already sold (today)
  3. Customers in the Cinema database
  4. The set of hours at which there are movies playing in a given room in the cinema.
  5. The set of places you can sit at in a room in the cinema.

Should I use catalogs, should I connect them directly to the Cinema concept with a multiplicity of * in the target?

Thanks

A: 

There is no correct design or wrong design in the software development industry. You can use either first or second method (i.e. you can use either catalog or connect them directly to the Cinema). But importantly you should be able to justify your design.

Upul
I agree with Upul. I would add that eventually you'll start to develop an intuition as to what you prefer. My $0.02 would be to use the first.
Raymond
+3  A: 

What is the role of Room Catalog?

Does it have other attributes/operations, or is it only acting as a container for Rooms?

Can you forsee creating multiple Room Catalogs associated with and over the lifetime of the Cinema instances?

Room Catalog kind of sounds to be more like something that you'd see in a the service layer and not in a domain model.

If it's not contributing structurally or behaviorally then I'd probably cull it and go with a simple association.

Ash Kim
"Can you forsee creating multiple Room Catalogs associated with and over the lifetime of the Cinema instances?" AH! This is a good point to think of. I don't think in this case I'll have multiple Room Catalogs.
devoured elysium
exactly the answer I was going to write
matt b
Also, could you extend a bit more about "Room Catalog kind of sounds to be more like something that you'd see in a the service layer and not in a domain model. " What is a Service Layer?
devoured elysium