mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 08:58:26 +00:00
docs: update delegation
This commit is contained in:
@@ -23,6 +23,10 @@ Real-world example
|
||||
|
||||
> In a restaurant, the head chef delegates tasks to sous-chefs: one manages grilling, another handles salads, and a third is in charge of desserts. Each sous-chef specializes in their area, allowing the head chef to focus on overall kitchen management. This mirrors the Delegation design pattern, where a main object delegates specific tasks to helper objects, each expert in their domain.
|
||||
|
||||
In plain words
|
||||
|
||||
> Delegation is a design pattern where an object passes on a task to a helper object.
|
||||
|
||||
Wikipedia says
|
||||
|
||||
> In object-oriented programming, delegation refers to evaluating a member (property or method) of one object (the receiver) in the context of another original object (the sender). Delegation can be done explicitly, by passing the sending object to the receiving object, which can be done in any object-oriented language; or implicitly, by the member lookup rules of the language, which requires language support for the feature.
|
||||
|
||||
Reference in New Issue
Block a user