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 faculties to represent another or others). The person who represents another is known as a delegate: his position and office are called a 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 discuss a possible bilateral trade agreement" , "The governor was very angry with the delegation from 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 power , although the delegator maintains ownership of the power.

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

The concept in Mexico and Spain

In Mexico , a delegation is a political and administrative division within a city. Mexico City , for example, is divided into sixteen delegations, which are further subdivided into colonias and barrios.

In Spain , meanwhile, the term Government Delegations refers to State bodies with a political character.

Computer

The concept of delegation is used in computing.

Delegation to IT

Delegation is a mechanism in object-oriented programming that involves entrusting a certain functionality from one class to another . It differs from inheritance in its selective reuse.

Let's see 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. Instead, 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, there are few programming languages ​​that implement delegation as an alternative model to static inheritance. Among the languages ​​that do offer this possibility is Self , born in the late 1980s.

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

Advantages of the method

Using delegation is a recommended practice as an alternative to inheritance whenever you do not need to cast upwards (converting an object to a lower-level type; for example: a Shape object to a Square object). Experts generally recommend it over inheritance in most cases, unless it is too complicated.

When working with a language that does not support direct delegation, 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 rather 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 method CalculateArea that receives a series of parameters, among which is typeOfFigure ; if it is desired 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 which does not expect the specification of the type of figure, and which always passes the same value for said parameter (that is, "square") to the method of class M.