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 6819361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:17:50+00:00 2026-05-26T21:17:50+00:00

I have a decorator chain that looks like this when initially created: IType calculator

  • 0

I have a decorator chain that looks like this when initially created:

IType calculator = new TypeADecorator(
                            new TypeBDecorator(
                                    new TypeCDecorator(
                                        new MyCalculator())));

Each of these decorators does a database look up to get a piece of data which is used in a calculation

However, not all of these decorators will be used each time. Therefore, there will potentially be redundant database calls that return nothing

So I am thinking it would better to dynamically create the decorator chain based on which ones do get used

e.g.

If I had a bool representing each one that gets used:

bool useTypeA;
bool useTypeB;
bool useTypeC;

Would I be able to somehow dynamically construct the necessary chain?

Bear in mind that it’s highly likely that other decorators will be added throughout the life of the app so I would like to come up with something that is quite flexable. Also, although there are only three decorators here, in reality there are about 8 used at the moment

  • 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-05-26T21:17:51+00:00Added an answer on May 26, 2026 at 9:17 pm

    I assume the database lookups are done in the constructor of the decarators, would not they be deferred? Would it be possible to design your decorators in a way that they do the database lookup whenever they really need the value from the db?

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

Sidebar

Related Questions

I have a decorator like this: def region_required(view_func): def new_view(request, ctx = {}, *args,
I have a decorator-like pattern with a base that requires a constructor parameter. The
Hi I have created a setDecorator() which is something like this: $timeSu->setDecorators(array('ViewHelper', 'Description', 'Errors',
Assuming I have a decorator and a wrapped function like this: def squared(method): def
I have created a new decorator and have added it to my form using
Suppose I have written a decorator that does something very generic. For example, it
I have a decorator that currently requires each function that uses it to have
I have this decorator, used to decorate a django view when I do not
I have been using this excellent decorator for memoization, which I found on the
I have a decorator that I wrote that will time a given function. It

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.