Skip to content

Instantly share code, notes, and snippets.

@ahmed2m
Created March 26, 2026 17:46
Show Gist options
  • Select an option

  • Save ahmed2m/afc5536799c24a5850662df10e30467e to your computer and use it in GitHub Desktop.

Select an option

Save ahmed2m/afc5536799c24a5850662df10e30467e to your computer and use it in GitHub Desktop.
Decorator Pattern
CharDescription base = new CharName("Aragorn");
CharDescription decorated =
new Who(
new Wearing(
new Granted(
new Bearer(
new Marked(base)
)
)
)
);
decorated.getDescription();
// "Aragorn; Marked by destiny; Bearer of the Ring; Granted the kingship; Wearing the crown; Who is the rightful king"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment