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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:45:46+00:00 2026-06-08T19:45:46+00:00

I have a GWT web application that uses the URL to navigate and the

  • 0

I have a GWT web application that uses the URL to navigate and the MVP pattern. For each URL I have a presenter to be called. I have about 20 differents presenters, and to decide which one to call, I use conditions like

if (view.equals("vue1")){
   presenter = new presenter1();
}else if(view.equals("vue2")){
   presenter = new presenter2();
}else if(view.equals("vue3") || vue.equals("vue4") || vue.equals("vue5")){
   presenter = new presenter345();
}
...

I tried another alternative, which is to load a HashMap at the starting of the application. The map contains the view as a key and the Presenter as the value. But it get complicated because I often have multiple keys (views) pointing to the same Presenter. So for the last condition in my example above, I will do something like this :

map.put("vue3",new Presenter345);
map.put("vue4",new Presenter345);
map.put("vue5",new Presenter345);

Questions :

1- Which one is efficient, knowing that the code is on the client side (JavaScript) ?

2- Is there another alternative ?

  • 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-08T19:45:47+00:00Added an answer on June 8, 2026 at 7:45 pm

    If you only have 20 or so, I wouldn’t really worry much about that. I would use a switch statement, and try to include the most likely views first. Or keep the if statements, and again test for the most likely condition first. But I suppose a hashmap will pretty much give you an average O(1), whereas an if statement or switch would give you average O(n)

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

Sidebar

Related Questions

I have gwt-project that is comunication to database. Application design mvp pattern and view
I have a GWT based web application that I have previously uploaded to Appspot.
I have a web application that is working fine under the following environment GWT
I have some doubts, i m developing a web application in GWT using MVP
I'm coding a web application in GWT. I have a class that handles all
I'm creating a web application with GWT. I have a method bookMode() that builds
I have a web application that I developed with the Google Web Toolkit (GWT),
I have a GWT web application that I have deployed in App engine, however
I have a GWT web application that creates a cache on disk under the
I have a gwt project that uses gwt-mosaic. Here is the error message I

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.