[rspec-users] Collection proxies need to be stubbed ?
dchelimsky at gmail.com
Sun Jan 21 18:51:19 EST 2007
On 1/21/07, Jay Levitt <lists-rspec at shopwatch.org> wrote:
> David Chelimsky wrote:
> > TDA says we shouldn't even ask the User for its Projects. It's the Law
> > of Demeter that says we shouldn't ask the User for it's Projects and
> > THEN ask the Projects whether they are active.
> Oops, my bad, then! So is it my misunderstanding of domain-driven
> design - especially the AGGREGATE pattern - or is TDA diametrically
> opposed to DDD here? Can we get Alec Sharp and Eric Evans in a boxing ring?
No - I think that's right. My read is that aggregate looks like the
antithesis of LoD, BUT, there is an important distinction to be made.
In DDD, the goal is ubiquitous language built around the business
domain. If the business domain says that there are Leagues that have
Conferences that have Teams that have Players, then those
relationships are very unlikely to change, and therefore minimize the
risks assoicated with LoD violations.
The real problem w/ LoD is when you see stuff like:
player = team.jersey_number_to_player_map
as opposed to
player = team.find_player_by_jersey_number
Even though it's not obvious, the first is an LoD violation. Here are
the same statements in java:
player = team.getJerseyNumberToPlayerMap().get("17")
as opposed to
player = team.findPlayerByJerseyNumber("17")
The fact that team stores players in a map is none of anybody's
business. The fact that it stores players is arguably a domain concept
that makes sense.
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users