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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:37:20+00:00 2026-06-08T15:37:20+00:00

Suppose we’ve the following structure of widgets / panels in a GWT application –

  • 0

Suppose we’ve the following structure of widgets / panels in a GWT application –

  • A Tree menu in the left of the DockLayoutPanel which is used for navigation to different applications.
  • A panel in the center of the DockLayoutPanel and different content widgets getting loaded in this panel (this is controlled by the navigation tree menu.
  • These content widgets are composites containing one or more widgets.

One way to deal with such application is to keep singletons for all widgets / panels, which means composites will hold singletons to all of their child widgets. But I feel this is excess usage of singleton. The other alternative is to construct new Widget object every time one is needed, but this must be expensive.

What are the best practices around this? Are there any standard patterns which take care of this problem?

  • 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-08T15:37:22+00:00Added an answer on June 8, 2026 at 3:37 pm

    The other alternative is to construct new Widget object every time one is needed, but this must be expensive.

    You’d be surprised. While Widget creation isn’t free, in most cases, it is pretty cheap, even in DevMode. There are several widgets that are expensive to create in DevMode (specifically, the FlexTable/Grid), but those speed up drastically once you compile the application.

    There doesn’t seem to be any pattern specifically for this, nor can I point to any one guru giving a best practice, but in our application we had previously treated all of our top level widgets as singletons and it caused a load of issues for us. (Managing state between different screens, handling event bus events, stale data on the screen when not cleared)

    We just refactored most of the code to be created on demand more (and subsequently destroyed when no longer needed) and we gained simpler code and a faster startup time.

    In the end, if you do create widgets on demand, there may be a few cases where you need to increase performance by making those widgets singletons, but I think you’ll find that only a few would warrant that effort.

    All in all, don’t assume something will be slow if you haven’t tried it, and don’t preemptively optimize your code.

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

Sidebar

Related Questions

Suppose the following constructor: class Needed { public: Needed () {} Needed (const char
Suppose we have the following: data Foo x from_list :: [x] -> Foo x
Suppose application has multiple apks for different countries. If US user with international roaming
Suppose I have the following table: PERSON : ID INT NAME STRING LASTNAME STRING
Suppose a mysql 5.5 server uses the following configuration for storing innodb data innodb_data_file_path
suppose I have the following serial C: int add(int* a, int* b, int n)
Suppose I have the following two tables: STUDENT studentid lastname firstname 1 Smith John
Suppose I have the following HTML: <div id=Wrapper> <div class=MyClass></div> <div class=MyClass></div> <div class=MyClass></div>
Suppose I have a file test.c containing the following: // line 1 // line
Suppose I have a ASP.NET Web API controller that uses a service, which in

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.