I think it's more important that each object is well encapsulated. Objects have methods that are either public or private (we'll leave it at that for now). As long as Object A has a concept of Object B (could be wired up via ColdSpring, or one object could be instantiated inside another object), and Object B has certain public methods, then Object A can access those public methods.
The idea behind proper encapsulation/data hiding is that if the implementation of a particular method changes, the objects that are currently accessing that method will be none the wiser. I've been working my way through the Object Oriented Thought Process (great book, highly recommended), and one of the examples they use is that a toaster object gets powered via an outlet object. How that outlet object itself gets powered is irrelevant to the toaster. it could be a hamster running on a wheel, it could be a nuclear power plant. But the toaster knows that when it says Outlet.giveMePower(), it gets what it needs from the outlet so that it can make yummy toast. if the outlet changes its implementation (lets say it starts using solar power), the toaster is none the wiser. It's still asking for the same method and as a result of calling that method, can get the power it needs. Bottom line is, the toaster shouldn't know (or care) -how- the giveMePower() method does what it does... just that it's there. On Tue, May 18, 2010 at 1:33 PM, Allen G <[email protected]> wrote: > Thanks! I figured I'd ask just to make sure + to see if I'm understanding > some of these concepts correctly myself. > > > In this case we're assuming the item _*has a*_ price instead of _may > have_ a price, correct? Or is that meaningless and what is important here > is that the two objects are well encapsulated, so to speak? > > --Allen > > On Tue, May 18, 2010 at 3:18 PM, Dan Wilson <[email protected]> wrote: > >> Think of a restaurant. The server knows how to talk to customers, explain >> menu options and take payment. >> >> The cook knows how to get ingredients, fiddle with knobs on the stove and >> put cooked food on a plate. >> >> There is going to be a server-cook interaction, but each largely retains >> specialized knowledge about their specific areas of control (knowledge) >> >> >> DW >> >> >> On Tue, May 18, 2010 at 4:15 PM, Doug Boude <[email protected]> wrote: >> >>> Yes, they're coupled in a sense, but in a controlled, OO acceptable >>> manner...some call it aggregation, some composition, but in either case, >>> you're injecting an instance of one object into another, and that's okay! :) >>> >>> >>> >>> On Tue, May 18, 2010 at 3:09 PM, Allen G <[email protected]> wrote: >>> >>>> Maybe I'm misunderstanding things but even if things are encapsulated, >>>> wouldn't one be coupling those two objects together by doing that? >>>> >>>> --Allen >>>> >>>> >>>> >>>> On Mon, May 17, 2010 at 9:23 PM, Dan Wilson <[email protected]> wrote: >>>> >>>>> Sure. That makes sense. >>>>> >>>>> I do it all the time. If you've encapsulated the Item stuff and the >>>>> Price stuff well enough, then you'd totally want to do that. >>>>> >>>>> DW >>>>> >>>>> >>>>> On Mon, May 17, 2010 at 10:17 PM, Brettski <[email protected]>wrote: >>>>> >>>>>> Hi, >>>>>> >>>>>> I have an item model, and a price model.. >>>>>> >>>>>> Is it OK in terms of OO theory to access the price model directly from >>>>>> the item model? >>>>>> >>>>>> b >>>>>> >>>>>> -- >>>>>> Model-Glue Sites: >>>>>> Home Page: http://www.model-glue.com >>>>>> Documentation: http://docs.model-glue.com >>>>>> Bug Tracker: http://bugs.model-glue.com >>>>>> Blog: http://www.model-glue.com/blog >>>>>> >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "model-glue" group. >>>>>> To post to this group, send email to [email protected] >>>>>> To unsubscribe from this group, send email to >>>>>> [email protected]<model-glue%[email protected]> >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/model-glue?hl=en >>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> William Osler - "We are here to add what we can to life, not to get >>>>> what we can from life." >>>>> >>>>> -- >>>>> Model-Glue Sites: >>>>> Home Page: http://www.model-glue.com >>>>> Documentation: http://docs.model-glue.com >>>>> Bug Tracker: http://bugs.model-glue.com >>>>> Blog: http://www.model-glue.com/blog >>>>> >>>>> You received this message because you are subscribed to the Google >>>>> Groups "model-glue" group. >>>>> To post to this group, send email to [email protected] >>>>> To unsubscribe from this group, send email to >>>>> [email protected]<model-glue%[email protected]> >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/model-glue?hl=en >>>>> >>>> >>>> -- >>>> Model-Glue Sites: >>>> Home Page: http://www.model-glue.com >>>> Documentation: http://docs.model-glue.com >>>> Bug Tracker: http://bugs.model-glue.com >>>> Blog: http://www.model-glue.com/blog >>>> >>>> You received this message because you are subscribed to the Google >>>> Groups "model-glue" group. >>>> To post to this group, send email to [email protected] >>>> To unsubscribe from this group, send email to >>>> [email protected]<model-glue%[email protected]> >>>> For more options, visit this group at >>>> http://groups.google.com/group/model-glue?hl=en >>> >>> >>> -- >>> Model-Glue Sites: >>> Home Page: http://www.model-glue.com >>> Documentation: http://docs.model-glue.com >>> Bug Tracker: http://bugs.model-glue.com >>> Blog: http://www.model-glue.com/blog >>> >>> You received this message because you are subscribed to the Google >>> Groups "model-glue" group. >>> To post to this group, send email to [email protected] >>> To unsubscribe from this group, send email to >>> [email protected]<model-glue%[email protected]> >>> For more options, visit this group at >>> http://groups.google.com/group/model-glue?hl=en >>> >> >> >> >> -- >> William Osler - "We are here to add what we can to life, not to get what >> we can from life." >> >> -- >> Model-Glue Sites: >> Home Page: http://www.model-glue.com >> Documentation: http://docs.model-glue.com >> Bug Tracker: http://bugs.model-glue.com >> Blog: http://www.model-glue.com/blog >> >> You received this message because you are subscribed to the Google >> Groups "model-glue" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected]<model-glue%[email protected]> >> For more options, visit this group at >> http://groups.google.com/group/model-glue?hl=en >> > > -- > Model-Glue Sites: > Home Page: http://www.model-glue.com > Documentation: http://docs.model-glue.com > Bug Tracker: http://bugs.model-glue.com > Blog: http://www.model-glue.com/blog > > You received this message because you are subscribed to the Google > Groups "model-glue" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<model-glue%[email protected]> > For more options, visit this group at > http://groups.google.com/group/model-glue?hl=en > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success. -- Model-Glue Sites: Home Page: http://www.model-glue.com Documentation: http://docs.model-glue.com Bug Tracker: http://bugs.model-glue.com Blog: http://www.model-glue.com/blog You received this message because you are subscribed to the Google Groups "model-glue" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/model-glue?hl=en
