I have products saved in my database that my system fetches with the following structure:

public class OriginalProduct {
   public string Id { get; set; }
   public string Name { get;set; }

I need to enrich the product with additional fields like a price, stock level, images, description etc. These are all fetched from different third party sources.

Would it make sense to create a "complete" product, e.g.

public class Product {
   public string Id { get; set; }
   public string Name { get; set; }
   public string Description { get; set; }
   public Price Price { get; set; }
   public Stock StockLevel { get; set; }
   public IEnumerable<Image> Images { get; set; }

and use a chain of decorators using the decorator pattern to populate the fields, using the original product as input?

1 Answer 1


The point of the decorator pattern is that you can configure many different combinations at construction. What you haven’t shown is any need for that power when talking to the database.

tl;dr: why?

  • Yes, it feels like a misuse of the pattern. I was thinking a bit if a pipeline or chain of responsibility pattern makes more sense, but at the end of the day I guess it's just a matter of object composition?
    – filur
    Oct 3, 2022 at 8:00
  • @filur still wondering what the motivation is. What do you need this flexibility for? Oct 3, 2022 at 12:38
  • The product is built up piece by piece so I guess I'm after some kind of pipeline rather than building it all in once class that injects all the services needed to construct it. As time progresses more and more features are added to it, so it would be nice with an extensible approach.
    – filur
    Oct 3, 2022 at 20:49
  • @filur you need to tell us WHY it's built up piece by piece. When it's built up. When that changes. If it's only ever added to or if it gets built differently... Sheesh just tell us why you want to do this. Just telling me you want to kill something doesn't tell me if need a sub machine gun, a nuke, or a fly swatter. Oct 3, 2022 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.