Steve Spicklemire wrote:
"Itai" == Itai Tavor <itai@optusnet.com.au> writes:
...
Itai> The 2nd way seems to go better with OO principles - all Itai> handling of photos is delegated to the Photos Specialist and Itai> the Product doesn't care if the photo exists or not, or Itai> where it comes from. But it also increases complexity in Itai> Photos, because I need to implement an efficient way to Itai> retrieve photos (with a Catalog, or SQL searches), and Itai> because it introduces the photo_key. Storing photo_id in Itai> Product eliminates these complexities, but it moves some of Itai> the responsibility for managing photos into Product.
Hmmm.. it seems to me that it makes more sense for the Product to know the id of the Photo that *it* needs to display itself than for the Photo to have to know that it belongs to a particular Product. Also.. I can imagine that the Photo class might be useful for lots of other things besides Products, and how would you teach it what type of object it belongs to?
Actually, my Photo object really is used for other things besides Products, which is where my problems with XOR connections come in... I myself prefer the first method (Product knowing the id of its Photo), but I've been bitten a lot recently by placing responsibilities outside the classes where they belong, so I'm trying hard to make sure I don't do it again.
Just my $0.02.
It's worth more than that to me :) -- Itai Tavor "Je sautille, donc je suis." C3Works itai@c3works.com - Kermit the Frog "If you haven't got your health, you haven't got anything"