Delegation Pattern and The By Keyword
  • Reads 1
  • Votes 0
  • Parts 1
  • Time <5 mins
  • Reads 1
  • Votes 0
  • Parts 1
  • Time <5 mins
Ongoing, First published Mar 19, 2024
The delegation pattern is a technique where an object expresses a certain behavior to the outside but simultaneously delegates responsibility for implementing that behavior to an associated object.

Let's understand this with the help of an example:
Let's say we want a printer. And a printer does what it is supposed to do. Let's create an interface to show this behavior.


interface Printer {
 void print(final String message);
}
All Rights Reserved
Sign up to add Delegation Pattern and The By Keyword to your library and receive updates
or
#58java
Content Guidelines
You may also like
Slide 1 of 1
Albatross cover

Albatross

34 parts Complete

Elliot's partner was his whole world, but after Allan's death, his ghost haunts Elliot's dreams. Everyone tells Elliot to move on, but he isn't sure he can. ***** It's been a year since the love of Elliot's life, Allan, passed away. Everyone thinks he should have recovered after that much time, but Allan still haunts Elliot every night. He struggles to maintain relationships with his family, and despite a coworkers interest he can't summon up the courage to date. Elliot is living for the past, because to live for the present means he'll have to live with a hole in his heart. But the question Elliot has to face chases him through his monotonous days: is mourning Allan with everything he has truly living? [[word count: 40,000-50,000 words]]