tags:

views:

35

answers:

1

Which one do you prefer and why?

  1. Reservation[] find(User user, Show show)
  2. Reservation[] find(long userId, long showId)

Thanks

+1  A: 

If you have a free choice, with no constraints, then I'd always choose the first. In fact, I'd also return a Collection, such as a List rather than an array.

The reason is that using domain objects rather than ids keeps focus on the business side of things, rather than on the relational aspects.

An interface dealing only in domain objects is also easier to mock, since you don't have to suddenly fabricate ids.

mdma