hello, everyone what is the difference between these terms, can you give please small examples thanks in advance
Aggregation: From http://en.wikipedia.org/wiki/Aggregate_pattern
In Design Patterns, an aggregate is not a design pattern but rather refers to an object such as a list, vector, or generator which provides an interface for creating iterators.
Meaning in short on elements contains 0 or more other elements of another type.
public class MyAggregation
{
protected List<MyAggregates> aggregates = new List<MyAggregates>();
public void add( MyAggregate element )
{
aggregates.Add( element );
}
}
Delegate: From http://en.wikipedia.org/wiki/Delegation_pattern
In software engineering, the delegation pattern is a design pattern in object-oriented programming where an object, instead of performing one of its stated tasks, delegates that task to an associated helper object
Meaning that some class uses another object to do something.
public interface IExceptionHandler
{
void handle( string filename );
}
public class FileDeleteExceptionHandler : IExceptionHandler
{
public void handle( string filename )
{
File.Remove( filename );
}
}
public class MyExceptionHandler
{
protected IExceptionHandler exceptionHandler;
public MyExceptionHandler( IExceptionHandler theHandler )
{
this.exceptionHandler = theHandler;
}
public void handleException( string filename )
{
excpetionHandler.handle( filename );
}
}
Or in C# delegation can just refer to a delegate function, see http://msdn.microsoft.com/de-de/library/900fyy8e%28VS.80%29.aspx
Consultation I know nothing off, sorry
hth
Mario
Note: I did not actually compile the code above.
There is a description of the difference between delegation and consultation here.
It would seem that what most folks refer to as delegation might more properly be referred to consultation.
I guess that delegation in the more formal sense described in the reference would be implemented as an Abstract base class delegating to a Concrete class.