Jump to content
  • Advertisement
Sign in to follow this  
Xloner12

Object taking an object

This topic is 3211 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to wrap my head around OOP and I was trying to create a simple program out of OOP. What I'm creating is a simple recipe box program. I have split it up into three objects as follows: Recipe Box: contains recipes files, can sort them by fields. Recipe Card: contains recipe itself and information Food List: takes text fields and orders them in sets to print out to paper My problem is that recipe box needs to take a recipe object or at the very abstract a card object. Am I planing this out wrong? should one class depend on another, I didn't think it should but I don't see a way around this yet? Any help or advice would be very great.

Share this post


Link to post
Share on other sites
Advertisement
It doesn't look wrong to me.. Having objects contain objects is not bad. In this case I think it is useful to have RecipeBox contain recipes.

Share this post


Link to post
Share on other sites
A Recipe Box is a "collection" of Recipes, it needs to know about Recipe objects in order to contain them, that's fine. Components have dependencies on other components, that's perfectly normal. It's possible to reduce coupling through various constructs like interfaces but you're still dependent on the interface.

The only thing there that looks a little squiff is the Food List, its description mentions nothing about food, so it sounds as if its name is overly specific. Could it really be more generically named, a Page Layout, or some such?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!