Sign in to follow this  
Xloner12

Object taking an object

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this