473,387 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Aggregation

Aggregation in COM was defined as 'Exposing an interface of an inner object
by the outer object as though it were an interface of the outer object'. Is
this type of aggregation possible in vb.net( or c#).
Nov 20 '05 #1
5 2765
Aggregation in COM worked by having all IUnknown calls go through the outter
object, and all QueryInterface calls on the outter object would include
calls to the inner object. In many ways, this was used to simulate the
object reuse effects of inheritance. In .NET, you can create a base class
object, then inherit that object in a derrived object. The derrived object
will automatically include the interfaces and implemenation of the base
class in addition to its own. However, there are nuances in inheritance that
aren't covered by aggregation and vice-versa. One thing to note is that in
..NET there is no multiple-inheritance. To get around this, you have to
delegate. In other words, you implement the interface of a contained object
in the container object, and manually delegate the calls to an inner object.

-Rob Teixeira [MVP]

"Nice Chap" <Ni******@PlasmaDyne.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Aggregation in COM was defined as 'Exposing an interface of an inner object by the outer object as though it were an interface of the outer object'. Is this type of aggregation possible in vb.net( or c#).

Nov 20 '05 #2
Aggregation in COM worked by having all IUnknown calls go through the outter
object, and all QueryInterface calls on the outter object would include
calls to the inner object. In many ways, this was used to simulate the
object reuse effects of inheritance. In .NET, you can create a base class
object, then inherit that object in a derrived object. The derrived object
will automatically include the interfaces and implemenation of the base
class in addition to its own. However, there are nuances in inheritance that
aren't covered by aggregation and vice-versa. One thing to note is that in
..NET there is no multiple-inheritance. To get around this, you have to
delegate. In other words, you implement the interface of a contained object
in the container object, and manually delegate the calls to an inner object.

-Rob Teixeira [MVP]

"Nice Chap" <Ni******@PlasmaDyne.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Aggregation in COM was defined as 'Exposing an interface of an inner object by the outer object as though it were an interface of the outer object'. Is this type of aggregation possible in vb.net( or c#).

Nov 20 '05 #3
dev
Rob,
I have been wondering how to handle a pattern as such:

Public Class Main

Public Class A
End Class

Public Class B
End Class

End Class

This seems to be a way around the single multiple inheritance limit. I
wonder if this is a good idea and, if it is, how would one implement
delegation in this example? If not, could you give some simple code on how
to delegate to handle the single multiple inheritance limit?
TIA,
Steve
"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote in message
news:un**************@TK2MSFTNGP09.phx.gbl...
Aggregation in COM worked by having all IUnknown calls go through the outter object, and all QueryInterface calls on the outter object would include
calls to the inner object. In many ways, this was used to simulate the
object reuse effects of inheritance. In .NET, you can create a base class
object, then inherit that object in a derrived object. The derrived object
will automatically include the interfaces and implemenation of the base
class in addition to its own. However, there are nuances in inheritance that aren't covered by aggregation and vice-versa. One thing to note is that in
.NET there is no multiple-inheritance. To get around this, you have to
delegate. In other words, you implement the interface of a contained object in the container object, and manually delegate the calls to an inner object.
-Rob Teixeira [MVP]

"Nice Chap" <Ni******@PlasmaDyne.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Aggregation in COM was defined as 'Exposing an interface of an inner

object
by the outer object as though it were an interface of the outer object'.

Is
this type of aggregation possible in vb.net( or c#).


Nov 20 '05 #4
dev
Rob,
I have been wondering how to handle a pattern as such:

Public Class Main

Public Class A
End Class

Public Class B
End Class

End Class

This seems to be a way around the single multiple inheritance limit. I
wonder if this is a good idea and, if it is, how would one implement
delegation in this example? If not, could you give some simple code on how
to delegate to handle the single multiple inheritance limit?
TIA,
Steve
"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote in message
news:un**************@TK2MSFTNGP09.phx.gbl...
Aggregation in COM worked by having all IUnknown calls go through the outter object, and all QueryInterface calls on the outter object would include
calls to the inner object. In many ways, this was used to simulate the
object reuse effects of inheritance. In .NET, you can create a base class
object, then inherit that object in a derrived object. The derrived object
will automatically include the interfaces and implemenation of the base
class in addition to its own. However, there are nuances in inheritance that aren't covered by aggregation and vice-versa. One thing to note is that in
.NET there is no multiple-inheritance. To get around this, you have to
delegate. In other words, you implement the interface of a contained object in the container object, and manually delegate the calls to an inner object.
-Rob Teixeira [MVP]

"Nice Chap" <Ni******@PlasmaDyne.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Aggregation in COM was defined as 'Exposing an interface of an inner

object
by the outer object as though it were an interface of the outer object'.

Is
this type of aggregation possible in vb.net( or c#).


Nov 20 '05 #5
Well, for starters, the classes don't have to be nested - classes A and B
can be defined outside Main if you like.
Next, Class Main can inherit from one of them - for this example, let's say
it's A. That takes care of one issue.
Before proceeding, you'll need to create an Interface for class B (let's
call it IClassB). This interface lists all the public members of B.
Now, you can implement IClassB in your class Main. For the implementation,
you'll need to create a private instance of B, and call that instance's
members from your implementation of IClassB in Main.

Public Interface IClassB
Sub DoSomething ( )
End Interface

Public Class B
Implements IClassB

Public Sub DoStuff ( ) Implements IClassB.DoStuff
' base implementation code goes here
End Sub
End Interface

Public Class Main
Inherits A
Implements IClassB

Private privateB As New B

Public Sub DoStuff( ) Implements IClassB.DoStuff
privateB.DoStuff( ) ' <--- delegation to class B instance here
End Sub
End Class

Again, there are nuances that prevent this from being a "true" substitution
of inheritance. For instance, Main has no way of dealing with B's Protected
members in this sample (unless you use Reflection and have enough access
permissions to invoke non-public members). But this should serve as a simple
example of the technique.

-Rob Teixeira [MVP]

"dev" <me@you.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Rob,
I have been wondering how to handle a pattern as such:

Public Class Main

Public Class A
End Class

Public Class B
End Class

End Class

This seems to be a way around the single multiple inheritance limit. I
wonder if this is a good idea and, if it is, how would one implement
delegation in this example? If not, could you give some simple code on how to delegate to handle the single multiple inheritance limit?
TIA,
Steve

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nice Chap | last post by:
Aggregation in COM was defined as 'Exposing an interface of an inner object by the outer object as though it were an interface of the outer object'. Is this type of aggregation possible in c#? ...
5
by: John Wood | last post by:
Let's say you're provided with an instance of a class. The instantiation takes place in another module that you have no control over. However, you've extended that class with your own value-added...
4
by: cmrchs | last post by:
Hi, how do I implement aggregation and how composition in C# ? When I say : an Airplane has a Pilot then I use aggregation but when I say : an Airplane has a Cockpit then I use composition. How...
2
by: Jozsef Bekes | last post by:
Hi, I would like to implement aggregation in C#, therefore I'd need to implement the queryinterface COM function of a class. I am not sure whether this can be done, and if yes where to start. If...
4
by: Frederik Vanderhaegen | last post by:
Hi, Can anyone explain me the difference between aggregation and composition? I know that they both are "whole-part" relationships and that composition parts are destroyed when the composition...
23
by: SenthilVel | last post by:
Hi Can any one let me know the websites/Pdf for learning Aggragation in C#?? Thanks Senthil
1
by: ninjutsu28 | last post by:
hi im juz a student so pls bear with my terminologies..juz wana ask how to perform aggregation in vb.net code.. in my model, i have rectangle, shape, drawing classes..rectangle class inherits...
7
by: Bruce One | last post by:
In C#, how would people implement a relationship between Customer class and Request class, considering a customer may have 0-n requests and a request must belong to 1 and only 1 customer...? ...
0
by: Karigar | last post by:
I have been so far developing COM servers and clients in C++. I am new to C#/NET way of doing COM and was wondering if it is possible to accomplish aggregation in .NET platform. By aggregation I...
6
by: Jeff | last post by:
hey Can OO Aggregation be described as: - A system of objects that are built using each other any comments? Jeff
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.