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

  • SEARCH
  • Home
  • 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 9004463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:54:05+00:00 2026-06-16T00:54:05+00:00

I was implementing a decorator the other day and later that night I started

  • 0

I was implementing a decorator the other day and later that night I started wondering if something like the example below was a valid representation of the decorator pattern.

public abstract class Foo
{
    public List<string> Names { get; set; }

    public abstract string GetNames();
}

public abstract class BarDecorator : Foo
{
    public abstract String GetNames();
}

public class JustAnOldBar : Foo
{
    public JustAnOldBar() {
        this.Names.Add("An Old Bar");
    }

    public override string GetNames()
    {
        return string.Join(",", this.Names.ToArray());
    }
}

public class SomeDecorator : BarDecorator {
    private Foo foo;

    public SomeDecorator(Foo someFoo) {
        this.foo = someFoo;
    }

    public override string GetNames()
    {
        return string.Join(",", this.Names) + "," + string.Join(",", this.foo.Names);
    }
}

Usually, when I implement this pattern, I’m looking at a single member that I’m pulling across like cost or description, but I wonder if it’s appropriate to operate on a collection with a decorator or if you should start looking at a builder when it comes to this point.

  • 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-16T00:54:06+00:00Added an answer on June 16, 2026 at 12:54 am

    Decorating, in the Decorator pattern, has no dependency of the fields (if any) that are involved in the decoration. It is about modifying the behavior of decorated classes. As exampled in the wiki definition, it might just as well decorate the drawing behavior of a window, rather than manipulate a field or return value of a method.

    In short – as Wiktor Zychla commented – no problem with that.

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

Sidebar

Related Questions

implementing service something similar with tinyurl or bit.ly, I'm would like to expose service
I'm implementing a decorator pattern in Javascript. I've seen the example here in Wikipedia
Implementing a custom membership provider, there are certain properties such as MinRequiredPasswordLength that only
When implementing the Strategy Pattern, where does one put the code that determines which
Effective Java , along with other sources suggest that we should consider using composition
Whilst implementing my first MVVM application in WPF, I've been wondering about the pros
I started to write a class which would act much like the std::vector but
Implementing custom DataAnnotationsModelMetadataProvider in ASP.NET MVC2. Assuming the object that is being rendered looks
I am implementing a custom IFormatter to serialize objects into a custom format that
I am implementing the moving box that's at the base of this page .

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.