This is a discussion on "extends" versus "aggregates" in UML CRC within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, This is just a trivial matter, I think the strictly technical answer is "whichever you prefer", but ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
This is just a trivial matter, I think the strictly technical answer is "whichever you prefer", but I find it interesting and I'm googling for brick walls so I'd like to hear what the general consensus is on this I've been trudging through the PHP docs & UML 1.5 specification to try and figure out whether it's correct to say "class a extends b" is an extension or an aggregation, in the context of a CRC diagram. I've been using extends up until now, but I have a feeling that aggregates is what I should be using. The problem is that PHP has (or had) it's own aggregation functions, so while it could be correct in other languages, and perhaps in PHP 5, to call it aggregation, in PHP 4 I have no idea. I'd appreciate your opinions on this - thanks in advance Sincerely, Kelvin |
|
|||
|
"Kelvin Mackay" <kelvin@nospam.sands-design.com> wrote in message news:opslreaw06krqzhn@snoopy... > Hi, > > This is just a trivial matter, I think the strictly technical answer is > "whichever you prefer", but I find it interesting and I'm googling for > brick walls so I'd like to hear what the general consensus is on this > > I've been trudging through the PHP docs & UML 1.5 specification to try and > figure out whether it's correct to say "class a extends b" is an extension > or an aggregation, in the context of a CRC diagram. > > I've been using extends up until now, but I have a feeling that aggregates > is what I should be using. The problem is that PHP has (or had) it's own > aggregation functions, so while it could be correct in other languages, > and perhaps in PHP 5, to call it aggregation, in PHP 4 I have no idea. > > I'd appreciate your opinions on this - thanks in advance > > Sincerely, > Kelvin Kelvin, In PHP, we say that class B "extends class A". In UML, I think we might call this an "association". Take a look at http://www.objectmentor.com/resource...ssDiagrams.pdf and see what you think. George |
|
|||
|
George King wrote:
> "Kelvin Mackay" <kelvin@nospam.sands-design.com> wrote in message > news:opslreaw06krqzhn@snoopy... > >>Hi, >> >>This is just a trivial matter, I think the strictly technical answer is >>"whichever you prefer", but I find it interesting and I'm googling for >>brick walls so I'd like to hear what the general consensus is on this >> >>I've been trudging through the PHP docs & UML 1.5 specification to try and >>figure out whether it's correct to say "class a extends b" is an extension >>or an aggregation, in the context of a CRC diagram. >> >>I've been using extends up until now, but I have a feeling that aggregates >>is what I should be using. The problem is that PHP has (or had) it's own >>aggregation functions, so while it could be correct in other languages, >>and perhaps in PHP 5, to call it aggregation, in PHP 4 I have no idea. >> >>I'd appreciate your opinions on this - thanks in advance >> >>Sincerely, >>Kelvin > > > Kelvin, > > In PHP, we say that class B "extends class A". In UML, I think we might > call this an "association". Take a look at > http://www.objectmentor.com/resource...ssDiagrams.pdf and see > what you think. > > George > > In my understanding of UML, an extension (or inheritance) is a separate issue from composition (or aggregation). - Extension/inheritance describes an "is-a" relationship. e.g. class Animal { int age; function think() { ... } function eat() { ... } } class Dog extends Animal { string breed; function wagTail() { ... } } A dog *is* an animal. - Aggregation/composition describes "has-a" relationship. This is a type of UML association. e.g. class Office { Worker manager; Worker employees[]; Desk desks[]; } An Office *has* a manager, *has* some employees, and *has* some desks. Two fundamentally different concepts. -- Oli |
|
|||
|
On Sun, 06 Feb 2005 17:16:03 GMT, Oli Filth
<oli_filth@eatspam.coldmail.com> wrote: > George King wrote: >> "Kelvin Mackay" <kelvin@nospam.sands-design.com> wrote in message >> news:opslreaw06krqzhn@snoopy... >> >>> Hi, >>> >>> This is just a trivial matter, I think the strictly technical answer >>> is "whichever you prefer", but I find it interesting and I'm googling >>> for brick walls so I'd like to hear what the general consensus is on >>> this >>> >>> I've been trudging through the PHP docs & UML 1.5 specification to try >>> and figure out whether it's correct to say "class a extends b" is an >>> extension or an aggregation, in the context of a CRC diagram. >>> >>> I've been using extends up until now, but I have a feeling that >>> aggregates is what I should be using. The problem is that PHP has (or >>> had) it's own aggregation functions, so while it could be correct in >>> other languages, and perhaps in PHP 5, to call it aggregation, in PHP >>> 4 I have no idea. >>> >>> I'd appreciate your opinions on this - thanks in advance >>> >>> Sincerely, >>> Kelvin >> Kelvin, >> In PHP, we say that class B "extends class A". In UML, I think we >> might call this an "association". Take a look at >> http://www.objectmentor.com/resource...ssDiagrams.pdf and >> see what you think. >> George > > In my understanding of UML, an extension (or inheritance) is a separate > issue from composition (or aggregation). > > - Extension/inheritance describes an "is-a" relationship. e.g. > > class Animal > { > int age; > > function think() { ... } > function eat() { ... } > } > > class Dog extends Animal > { > string breed; > > function wagTail() { ... } > } > > A dog *is* an animal. > > - Aggregation/composition describes "has-a" relationship. This is a type > of UML association. e.g. > > class Office > { > Worker manager; > Worker employees[]; > Desk desks[]; > } > > An Office *has* a manager, *has* some employees, and *has* some desks. > > Two fundamentally different concepts. > Thanks for your replies - the document & example have certainly made things clearer. In the PDF I noticed a relationship that I somehow hadn't considered - "inherit". I think this most accurately describes the 'extends' operation, so I'll use it from now on. Thanks for your clarification of aggregation, I'll find it very useful now that I know how to use it! Kelvin |