PC Review


Reply
 
 
aaj
Guest
Posts: n/a
 
      16th Mar 2005
Hi

is it possible in VB.NET to aggregate two classes, if so could you tell me
how its done?

I have been looking for a while and can't find any examples that actually
show the physical code. Perhaps I'm using the wrong terminology?

thanks in advance

Andy


 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      16th Mar 2005
aaj,

I don't know if it is the wrong terminology, however some weeks ago I saw a
very long discussiong because somone had another meaning of the word
aggregate and they started a discussion about that.

Therefore what do you mean with aggregate by this.

Cor


 
Reply With Quote
 
aaj
Guest
Posts: n/a
 
      16th Mar 2005
Hi Cor

Say I have class A ,class B and class C all three are unique and different.

for instance a wheel, a pedal and a handlebar

I DONT want Class C to inherit from class B which inherits from Class A.
i.e. I dont want an 'IS A' type relationship

what I want to make is a new class D that contains selected methods from
class A, selected methods from class B and selected methods from class C
i.e. they are 'parallel' with each other. i.e. a 'Has a' type relationship

The thing I'm trying to achieve is shown by either an open or filled diamond
shape in uml 2.0

Thanks

Andy


"Cor Ligthert" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> aaj,
>
> I don't know if it is the wrong terminology, however some weeks ago I saw
> a very long discussiong because somone had another meaning of the word
> aggregate and they started a discussion about that.
>
> Therefore what do you mean with aggregate by this.
>
> Cor
>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      16th Mar 2005
Cor,

"Cor Ligthert" <(E-Mail Removed)> schrieb:
> I don't know if it is the wrong terminology, however some weeks ago I saw
> a very long discussiong because somone had another meaning of the word
> aggregate and they started a discussion about that.
>
> Therefore what do you mean with aggregate by this.


<URL:http://en.wikipedia.org/wiki/Aggregation_%28object-oriented_programming%29>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      16th Mar 2005
Herfried,

Thanks, you should have read a long thread I thought in the general
newsgroup where 2 persons were almost killing each other because of that one
of those had used aggregate and the other had onother meaning of aggregate.
The one who used it is let us say "more theoretic than me."

:-)

Cor


 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      16th Mar 2005
aaj,

You mean that your car has a property wheel, a property pedal and a propety
handlebar.

The value of those are a wheelobject a pedalobject and a handlebar object.
Because it is a class, it are not collections?

I don't think that a car has methods from a wheel, a pedal or a handlebar
that are carparts.

Thererfore you can have a class carparts.

And a class wheel, pedal and handlebar, which inherits than from carparts.

Is that what you mean?

Cor


 
Reply With Quote
 
aaj
Guest
Posts: n/a
 
      16th Mar 2005
Similar but not exactly

I want to have a wheel that is a base class, a pedal thats a base class and
a handlebar thats a base class

I want a new object called a bike that is an aggregate of a wheel, a
handlebar and a pedal

i.e. my bike 'has a' handlebar and 'has a' wheel (its a unicycle) and 'has
a' pedal (only one at this stage)


I hope I'm asking the right question here, but I'm pretty sure I'm not
looking for inheritance

hope it makes sense

Andy



"Cor Ligthert" <(E-Mail Removed)> wrote in message
news:%23iV$(E-Mail Removed)...
> aaj,
>
> You mean that your car has a property wheel, a property pedal and a
> propety handlebar.
>
> The value of those are a wheelobject a pedalobject and a handlebar object.
> Because it is a class, it are not collections?
>
> I don't think that a car has methods from a wheel, a pedal or a handlebar
> that are carparts.
>
> Thererfore you can have a class carparts.
>
> And a class wheel, pedal and handlebar, which inherits than from carparts.
>
> Is that what you mean?
>
> Cor
>



 
Reply With Quote
 
Alex Clark
Guest
Posts: n/a
 
      16th Mar 2005
Hi aaj,

I would suggest defining interfaces for IWheel, IPedal, and IHandlebar, then
having Class A, B or C implementing those interfaces where appropriate. If
the implementation is common (ie IWheel.Rotate would be implemented the same
in Class A, B or C) then I would have an internal Friend class which
provides the common code for this that you can just call into, therefore
preventing duplication of code.

I believe what you really want to accomplish would be possible if .NET
supported multiple object inheritance, which it doesn't (however I believe
C++ does?). That way, Class A could inherit from Wheel and Pedal, Class B
could inherit from Pedal and Handlebar etc. I've always this would be a
nice feature in .NET, but I can understand why MS chose not to implement it
as part of the CLR.

Cheers,
Alex Clark




"aaj" <(E-Mail Removed)> wrote in message
news:1110976489.97a40d25aacc114017a25adca7919426@teranews...
> Similar but not exactly
>
> I want to have a wheel that is a base class, a pedal thats a base class
> and a handlebar thats a base class
>
> I want a new object called a bike that is an aggregate of a wheel, a
> handlebar and a pedal
>
> i.e. my bike 'has a' handlebar and 'has a' wheel (its a unicycle) and 'has
> a' pedal (only one at this stage)
>
>
> I hope I'm asking the right question here, but I'm pretty sure I'm not
> looking for inheritance
>
> hope it makes sense
>
> Andy
>
>
>
> "Cor Ligthert" <(E-Mail Removed)> wrote in message
> news:%23iV$(E-Mail Removed)...
>> aaj,
>>
>> You mean that your car has a property wheel, a property pedal and a
>> propety handlebar.
>>
>> The value of those are a wheelobject a pedalobject and a handlebar
>> object.
>> Because it is a class, it are not collections?
>>
>> I don't think that a car has methods from a wheel, a pedal or a handlebar
>> that are carparts.
>>
>> Thererfore you can have a class carparts.
>>
>> And a class wheel, pedal and handlebar, which inherits than from
>> carparts.
>>
>> Is that what you mean?
>>
>> Cor
>>

>
>



 
Reply With Quote
 
Larry Lard
Guest
Posts: n/a
 
      16th Mar 2005

aaj wrote:
> Similar but not exactly
>
> I want to have a wheel that is a base class, a pedal thats a base

class and
> a handlebar thats a base class
>
> I want a new object called a bike that is an aggregate of a wheel, a
> handlebar and a pedal
>
> i.e. my bike 'has a' handlebar and 'has a' wheel (its a unicycle) and

'has
> a' pedal (only one at this stage)


Public Class Bike
Public bikehandle As Handlebar
Public bikewheel As Wheel
Public bikepedal As Pedal
End Class

(implement with formal properties rather than public members if you
prefer)

Is this good enough?

--
Larry Lard
Replies to group please

 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      16th Mar 2005
aaj,

Change the word car completly for bicycle in my message.

I gave exactly the answer.

A wheel can be a base class for the front wheel and the backwheel because
they are on a bike completly different . However a pedal can never be a
baseclass in this situation.

A bike has pedals, a pedal has a cone.
However a pedal has not a bike, not a wheel and as well not a handle.

It is possible to inherit a bike from a class bicycle part, however I would
not do that because it is the top of the three and has only properties that
aggregate as you saw..

You get than what Larry wrote and than as well something as

Class bicyclepart
Public property colour

Class wheel
inherits bicyclepart
Public property spokes as spoke "an object that as well inherits from
bicyclepart
etc

Class pedal
inherits bicyclepart
public side as enumside

Class handle
inherits bicyclepart
public side as enumside


Cor


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Aggregation... =?Utf-8?B?VGVkIEJ1b3k=?= Microsoft Excel Misc 2 11th Jun 2007 08:15 PM
Aggregation in C# =?Utf-8?B?QnJ1Y2UgT25l?= Microsoft Dot NET 7 4th Sep 2006 11:36 PM
aggregation in C# Jozsef Bekes Microsoft C# .NET 0 26th May 2005 03:43 PM
Aggregation Nice Chap Microsoft VB .NET 3 12th Jan 2004 06:07 PM
COM Aggregation in VB.NET Mike Hamsa Microsoft VB .NET 2 22nd Oct 2003 02:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:56 AM.