Re: Association and depency
From: Daniel T. (postmaster_at_eathlink.net)
Date: 05/30/04
- Next message: Daniel T.: "Re: Association and depency"
- Previous message: Daniel T.: "Re: Adding abstract class..."
- Next in thread: Daniel T.: "Re: Association and depency"
- Maybe reply: Daniel T.: "Re: Association and depency"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 30 May 2004 14:35:46 GMT
In article <FSGic.19401$_o3.621107@bgtnsc05-news.ops.worldnet.att.net>,
"bobsled" <sleding@sands.com> wrote:
>Daniel T. <postmaster@eathlink.net> wrote in message
>news:postmaster-0B8918.17392724042004@news4.west.earthlink.net...
>> "bobsled" <sleding@sands.com> wrote:
>>
>> > Would you please check the code example blow to see if Association and
>> > Dependency are represented correctly in code? Thank you very much!
>> >
>> > class License;
>> >
>> > class Car;
>> >
>> > class Driver
>> > {
>> > Car* hiscar;//ASSOCIATION - Driver is associated with Car
>> > public:
>> > void own(License* l) { l->getLicenseNumber(); } // DEPENDENCY
>> > }
>>
>> Driver is associated with License in the above code. We can tell because
>> Driver objects send messages to License objects. A dependency would be
>> more like:
>>
>> class Factory {
>> public:
>> Car* makeCar() { return new Car; }
>> };
>>
>> Here the Car class must exist in order for the Factory class to work,
>> howver the Factory objects send no messages to Car objects, they make no
>> demands on the Car interface.
>
>In what sense do you mean that "Car class must exist in order for the
>Factory class to work"? Because that "Factory" is for making objects of
>"Car"? However I do see "Factory" can "exist" without creating "Car"...
This particular factory is a car factory, as such the car class must
exist in order for the car factory to make cars.
- Next message: Daniel T.: "Re: Association and depency"
- Previous message: Daniel T.: "Re: Adding abstract class..."
- Next in thread: Daniel T.: "Re: Association and depency"
- Maybe reply: Daniel T.: "Re: Association and depency"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|