Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8831429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:18:25+00:00 2026-06-14T08:18:25+00:00

What is the difference between Decorator pattern and Delegation pattern (if there is any)

  • 0

What is the difference between Decorator pattern and Delegation pattern (if there is any) ? I don’t want to know just about implementation details but also about use case differencies and subjective point of view how to use them.

  • Decorator pattern
  • Delegation pattern

EDIT : Can you point to source code (in OS project) where these pattern (especially Delegation, because Decoration is used in Java IO classes) are used. I’m looking for some real usage not just dummy example. Maybe these patterns are the same differs only in title. Feel free to write this opinion.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:18:26+00:00Added an answer on June 14, 2026 at 8:18 am

    Decorator uses Delegation, but in a very specific way.

    Delegation (or composition) is not as much a pattern as a general way to build complex behavior by coordinating use of several other objects. It’s often used in a set or static way. By "set or static" I mean something like this:

    class Delegator {
      private final ClassA a = new ClassA();
      private final ClassB b = new ClassB();
    
      public void doWork() {
         a.setup();
         final ResFromA resa = a.getRes();
         b.setup();
         b.consume(resa);
      }
    
    }
    

    Note that Delegator does not share any type or interface with either ClassA or ClassB, and knows the exact type of both a and b.

    Decorator is a dynamic way to use delegation to add behavior to a logical entity at runtime. In Decorator all entities share a common interface, and use delegation to concatenate their work.

    public interface Item {
      public void drawAt(final int x, final int y);
    }
    
    public class CircleAround implements Item {
      private final Item wrapped;
      private final int radius;
    
      public CircleAround(public final Item wrapped, public final int radius) {
        this.wrapped = wrapped;
        this.radius = radius;
      }
      
      public void drawAt(final int x, final int y) {
        // First handle whatever we are wrapping
        wrapped.drawAt(x,y);
        // Then add our circle
        Graphics.drawCircle(x, y, radius);
      }
    
    }
    

    Note that unlike the first example, CircleAround does not know the exact type of the item that it wraps, and shares a common interface with it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any tangible difference between the two forms of syntax available for creating
Is there any difference between ReferencePath with condition '%(CopyLocal)'=='true' and ReferenceCopyLocalPaths ? The question
Is there a difference between these two location of a decorator ? def a():
Are there any practical difference between the two coding patterns in Delphi: Version 1
What is the difference between the Composite Pattern and Decorator Pattern?
What is the difference between Python decorators and the decorator pattern? When should I
Difference between Calendar & Date Picker control in WPF? Is there any criteria of
Is difference between foldl and foldr just the direction of looping? I thought there
JAVA : is there a difference between the two references p && pp? PrintStream
Can any one explain difference between position and anchor point in cocos-2D with some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.