Definition of

Delegation

Delegate

Delegation is the act and result of delegating.

Delegation is the action and effect of delegating (giving a person or group the necessary powers and powers to represent another or others). He who represents another is known as a delegate: his position and office are called delegation.

The term is also used to name the team or work group that represents a community or a country. For example: "The Chilean delegation arrived on African soil after a fourteen-hour flight" , "A Chinese delegation met with the Uruguayan president to analyze a possible bilateral trade agreement" , "The governor was very angry with the Uruguayan delegation" . the North American company that tried to violate internal regulations .

Delegation in administrative law

In the field of administrative law , delegation is the transfer from a higher body to a lower body of the exercise of a competence , although the delegator maintains ownership of the same.

The delegation is carried out through an administrative act and can be revoked by the delegator.

The concept in Mexico and Spain

In Mexico , the delegation is a political and administrative division within a city. Mexico City , for example, is divided into sixteen delegations which, in turn, are subdivided into colonies and neighborhoods.

In Spain , meanwhile, we speak of Government Delegations to refer to State bodies with a political nature.

Computer

The concept of delegation is used in computing.

IT Delegation

A mechanism of object-oriented programming that consists of entrusting a certain functionality of one class to another is known as delegation. It differs from inheritance by its selective reuse.

Let's look at a practical example: a class A has a method to calculate the area of ​​any given geometric figure; However, it does not have the tools to perform the calculations itself but, once the figure has been analyzed, it delegates the action to the appropriate class through a call to the relevant method, to finally return the result.

Despite being a widely known practice, few programming languages ​​implement delegation as an alternative model to static inheritance. Among the languages ​​that do offer this possibility is Self , born at the end of the 80s.

The concept of multicast delegate refers to a delegate that points to multiple methods. It is a mechanism that offers the possibility of executing more than one method, similar to the case of surface calculation explained above.

Advantages of the method

The use of delegations is an advisable practice as an alternative to inheritance as long as upward conversions are not needed (converting an object to a lower hierarchy type; for example: an object from class Shape to class Square ). Experts recommend it over inheritance in most cases, unless it is too complicated.

When working with a language that does not support delegation directly, it is possible to emulate it through class composition (hosting an object from a different class in a class and making it private, so that the user cannot see its original interface but that of the class that contains it) to delegate certain tasks to objects that are capable of solving them.

It is worth mentioning that the use of a delegate method is not always done through one with the same number and type of parameters; For example: in a class M there is a CalcularArea method that receives a series of parameters, among which is FigureType ; If you want to use it from a class C , which only operates with squares, then said class may have a method with a name similar to the original, but that does not wait for the specification of the type of figure, and that passes to the method of class M always the same value for said parameter (that is, "square").