1 / 351

Delegation

Learn about programming delegation, a powerful language feature and design pattern that involves handing tasks from one object to another for enhanced code readability and flexibility. Understand its significance in object-oriented programming and its application in various programming languages.

wathen
Download Presentation

Delegation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Delegation https://store.theartofservice.com/the-delegation-toolkit.html

  2. Delegation (programming) • Most commonly, it refers to a programming language feature making use of the method lookup rules for dispatching so-called self-calls as defined by Lieberman in his 1986 paper "Using Prototypical Objects to Implement Shared Behavior in Object-Oriented Systems". Delegation as a language feature supports the prototype-based programming model. https://store.theartofservice.com/the-delegation-toolkit.html

  3. Delegation (programming) • In its original usage, delegation refers to one object relying upon another to provide a specified set of functionalities. In research, this is often referred to as consultation or as aggregation in modeling. https://store.theartofservice.com/the-delegation-toolkit.html

  4. Delegation (programming) • In CLI, a delegate is a form of type-safe function pointer usually used in an observer pattern as a means telling which method to call when an event is triggered, keeping the method type. https://store.theartofservice.com/the-delegation-toolkit.html

  5. Delegation (programming) • Despite delegation being fairly widespread, relatively few major programming languages implement delegation as an alternative model to static inheritance. The Self programming language incorporates the notion of delegation through its notion of mutable parent slots that are used upon method lookup on self calls. https://store.theartofservice.com/the-delegation-toolkit.html

  6. Delegation (programming) • In object-oriented programming, a multicast delegate is a delegate that points to several methods. Multicast delegation is a mechanism that provides functionality to execute more than one method. There is a list of delegates maintained internally, and when the multicast delegate is invoked, the list of delegates is executed. https://store.theartofservice.com/the-delegation-toolkit.html

  7. Delegation (programming) - Design pattern • Delegation is the simple yet powerful concept of handing a task over to another part of the program. In object-oriented programming it is used to describe the situation where one object assigns a task to another object, known as the delegate. This mechanism is sometimes referred to as aggregation, consultation or forwarding (when a wrapper object doesn't pass itself to the wrapped object). https://store.theartofservice.com/the-delegation-toolkit.html

  8. Delegation (programming) - Design pattern • Delegation is dependent upon dynamic binding, as it requires that a given method call can invoke different segments of code at runtime https://store.theartofservice.com/the-delegation-toolkit.html

  9. Delegation (programming) - Design pattern • It has been argued that delegation may in some cases be preferred for inheritance to make program code more readable and understandable. https://store.theartofservice.com/the-delegation-toolkit.html

  10. Delegation (programming) - Language feature • Delegation can be termed "run-time inheritance for specific objects". https://store.theartofservice.com/the-delegation-toolkit.html

  11. Delegation (programming) - Language feature • // "this" also known under the names "current", "me" and "self" in other languages https://store.theartofservice.com/the-delegation-toolkit.html

  12. Delegation (programming) - Language feature • Calling b.foo() will result in a.bar being printed, since class B "delegates" the method foo() to a given object of class A. https://store.theartofservice.com/the-delegation-toolkit.html

  13. Delegation (programming) - Language feature • Lava uses an explicit delegation link that can never be null, and can never change during an object's lifetime https://store.theartofservice.com/the-delegation-toolkit.html

  14. Delegation (programming) - Dual inheritance • If the language supports both delegation and inheritance one can do dual inheritance by utilizing both mechanisms at the same time as in https://store.theartofservice.com/the-delegation-toolkit.html

  15. Delegation (programming) - Dual inheritance • This calls for additional rules for method lookup, as there are now potentially two methods that can be denoted as the most specific (due to the two lookup paths). This is elaborated in K. Graversen's Ph.D. thesis on roles. https://store.theartofservice.com/the-delegation-toolkit.html

  16. Delegation (programming) - Related areas • Delegation can be described as a low level mechanism for sharing code and data between entities. Thus it builds the foundation for other language constructs. Notably role-oriented programming languages have been utilizing delegation but especially the older ones factually used aggregation while claiming to use delegation. This should not be considered cheating, merely the plural definitions of what delegation means (as described above). https://store.theartofservice.com/the-delegation-toolkit.html

  17. Delegation (programming) - Related areas • More recently work has also been done on distributing delegation, so e.g. clients of a search engine (finding cheap hotel rooms) can use a shared entity using delegation to share best hits and general re-usable functionality. https://store.theartofservice.com/the-delegation-toolkit.html

  18. Delegation (programming) - Related areas • Delegation has also been suggested for advice resolution in aspect-oriented programming by Ernst and Lorenz in 2003. https://store.theartofservice.com/the-delegation-toolkit.html

  19. Delegation (programming) - Related areas • Delegation is a fundamental technique used in languages of prototype-based programming (such as JavaScript). https://store.theartofservice.com/the-delegation-toolkit.html

  20. Delegation (programming) - Method type delegation • In C#, a delegate is a way of telling which method to call when an event is triggered. For example, if you click a Button on a form, the program would call a specific method. It is this pointer that is a delegate. Delegates are good because you can notify several methods that an event has occurred, if you so wish. https://store.theartofservice.com/the-delegation-toolkit.html

  21. Delegation (programming) - "Singlecast" delegates (C#) • delegate void Notifier(string sender); // Normal method signature with the keyword delegate https://store.theartofservice.com/the-delegation-toolkit.html

  22. Delegation (programming) - "Singlecast" delegates (C#) • void HowAreYou(string sender) { https://store.theartofservice.com/the-delegation-toolkit.html

  23. Delegation (programming) - "Singlecast" delegates (C#) • Console.WriteLine("How are you, " + sender + '?'); https://store.theartofservice.com/the-delegation-toolkit.html

  24. Delegation (programming) - "Singlecast" delegates (C#) • greetMe = new Notifier(HowAreYou); https://store.theartofservice.com/the-delegation-toolkit.html

  25. Delegation (programming) - "Singlecast" delegates (C#) • greetMe("Anton"); // calls HowAreYou("Anton") and prints "How are you, Anton?" https://store.theartofservice.com/the-delegation-toolkit.html

  26. Delegation (programming) - "Singlecast" delegates (C#) • Delegate variables are first-class objects of the form new DelegateType(obj.Method) and can be assigned to any matching method, or to the value null. They store a method and its receiver without any parameters: https://store.theartofservice.com/the-delegation-toolkit.html

  27. Delegation (programming) - "Singlecast" delegates (C#) • The object funnyObj can be this and omitted. If the method is static, it should not be the object (also called an instance in other languages), but the class itself. It should not be abstract, but could be new, override or virtual. https://store.theartofservice.com/the-delegation-toolkit.html

  28. Delegation (programming) - "Singlecast" delegates (C#) • To call a method with a delegate successfully, the method signature has to match the DelegateType with the same number of parameters of the same kind (ref, out, value) with the same type (including return type). https://store.theartofservice.com/the-delegation-toolkit.html

  29. Delegation (programming) - Multicast delegates (C#) • A delegate variable can hold multiple values at the same time: https://store.theartofservice.com/the-delegation-toolkit.html

  30. Delegation (programming) - Multicast delegates (C#) • void HowAreYouToday(string sender) { https://store.theartofservice.com/the-delegation-toolkit.html

  31. Delegation (programming) - Multicast delegates (C#) • greetMe += new Notifier(HowAreYouToday); https://store.theartofservice.com/the-delegation-toolkit.html

  32. Delegation (programming) - Multicast delegates (C#) • greetMe -= new Notifier(HowAreYou); https://store.theartofservice.com/the-delegation-toolkit.html

  33. Delegation (programming) - Multicast delegates (C#) • greetMe("Pereira"); // "How are you today, Pereira?" https://store.theartofservice.com/the-delegation-toolkit.html

  34. Delegation (programming) - Multicast delegates (C#) • If the multicast delegate is a function or has no out parameter, the parameter of the last call is returned. https://store.theartofservice.com/the-delegation-toolkit.html

  35. Prototype-based programming - Delegation • All that is required to establish this behavior-sharing between objects is the delegation pointer https://store.theartofservice.com/the-delegation-toolkit.html

  36. European Parliament - Committees and delegations • The Parliament has 20 Standing Committees consisting of 28 to 86 MEPs each (reflecting the political makeup of the whole Parliament) including a Chairman, a bureau and secretariat https://store.theartofservice.com/the-delegation-toolkit.html

  37. European Parliament - Committees and delegations • Committees can also set up sub-committees (e.g https://store.theartofservice.com/the-delegation-toolkit.html

  38. European Parliament - Committees and delegations • The nature of the committees differ from their national counterparts as, although smaller in comparison to those of the United States Congressional committee|United States Congress, the European Parliament's committees are unusually large by European standards with between eight and twelve dedicated members of staff and three to four support staff. Considerable administration, archives and research resources are also at the disposal of the whole Parliament when needed. https://store.theartofservice.com/the-delegation-toolkit.html

  39. European Parliament - Committees and delegations • They include Interparliamentary delegations (maintain relations with Parliament outside the EU), joint parliamentary committees (maintaining relations with parliaments of states which are candidates or associates of the EU), the delegation to the ACP EU Joint Parliamentary Assembly and the delegation to the Euro-Mediterranean Parliamentary Assembly https://store.theartofservice.com/the-delegation-toolkit.html

  40. 6to4 - Reverse DNS delegation • When a site using 6to4 has a fixed global IPv4 address, its 6to4 IPv6 prefix is also fixed. It is then possible to request reverse DNS delegation for an individual 6to4 48-bits prefix inside the 2.0.0.2.ip6.arpa DNS zone from the Number Resource Organization at [http://6to4.nro.net/] . The process is entirely automatic. https://store.theartofservice.com/the-delegation-toolkit.html

  41. Server-side JavaScript - Implicit and Explicit Delegation • JavaScript is a Delegation (programming)|Delegation Language. https://store.theartofservice.com/the-delegation-toolkit.html

  42. Server-side JavaScript - Implicit and Explicit Delegation • ; Functions as Roles (Traits and Mixins): JavaScript natively supports various function based implementations of Role-oriented programming|Role patterns like Traits (computer science)|Traits[https://github.com/petsel/javascript-code-reuse-patterns/tree/master/source/components/composition/ JavaScript Code Reuse Patterns], April 19, 2013 https://store.theartofservice.com/the-delegation-toolkit.html

  43. Server-side JavaScript - Implicit and Explicit Delegation • Thus Inheritance (computer science)|inheritance in JavaScript is covered by a delegation automatism that is bound to the prototype property of constructor functions. https://store.theartofservice.com/the-delegation-toolkit.html

  44. Prototype-based - Delegation • All that is required to establish this behavior-sharing between objects is the delegation pointer https://store.theartofservice.com/the-delegation-toolkit.html

  45. Self (programming language) - Inheritance/Delegation • Delegation can also be used to implement features such as namespaces and lexical scoping. https://store.theartofservice.com/the-delegation-toolkit.html

  46. Self (programming language) - Inheritance/Delegation • For example, suppose an object is defined called bank account, that is used in a simple bookkeeping application. Usually, this object would be created with the methods inside, perhaps deposit and withdraw, and any data slots needed by them. This is a prototype, which is only special in the way it is used since it also happens to be a fully functional bank account. https://store.theartofservice.com/the-delegation-toolkit.html

  47. List of United States congressional districts - Non-voting delegations • * 1861–1889 (obsolete since statehood as North Dakota and South Dakota) https://store.theartofservice.com/the-delegation-toolkit.html

  48. List of United States congressional districts - Non-voting delegations • * 1806–1812 (obsolete since statehood as Louisiana) https://store.theartofservice.com/the-delegation-toolkit.html

  49. Namespaces - Delegation • Namespaces allow delegation of identifier assignment to multiple name issuing organisations whilst retaining global uniqueness https://store.theartofservice.com/the-delegation-toolkit.html

  50. Prefix delegation • In IPv6 networking, 'prefix delegation' is used to assign a network address prefix to a user site, configuring the user's router (computing)|router with the prefix to be used for each LAN. This is one of the methods for delegating IPv6 address prefixes to an IPv6 subscriber's network (or site). It is described by RFC 3769. https://store.theartofservice.com/the-delegation-toolkit.html

More Related