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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:28:59+00:00 2026-06-10T12:28:59+00:00

Let’s do it with an example. Let’s consider a Company entity that has a

  • 0

Let’s do it with an example. Let’s consider a Company entity that has a functionality to retrieve the employees – getEmployees(). A company may have lots of employees so the employees are not loaded when the Company is loaded. But, once the employees were loaded, they are saved in the cache and will be retrieved immediately upon next invocation.

Now I would like to present the list of employees in a list view – GUI.

I would like to provide a ‘loading’ indication, while the employees are loaded from the internet.

But, when loaded from the cache (very fast) it would be an annoyance to present the ‘loading’ indicator and drop it immediately. So, when already loaded, I would NOT want to show the ‘loading’ indicator at all.

How would you tackle this design question? Would you add a method getCachedEmployees()? Perhaps isEmployeesCached()? Perhaps change the method to getEmployees(boolean cache)?

I don’t like any of the above because instead of encapsulating the cache, the cache is emphasized – thus complicating the software.

Any other ideas?

  • 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-10T12:29:01+00:00Added an answer on June 10, 2026 at 12:29 pm

    I assume that you have your GUI and code for displaying and managing your GUI elements decoupled from your application logic and data.

    I understand that if some action in the GUI triggers the application logic to load the employees, you just want to invoke the getEmployees() method. Your GUI should not control if data is loaded from the cache or internet. But you need a logic in the GUI to decide if the loading indication needs to be displayed.

    The best solution I can think of would be that your GUI has something like a timer – you invoke the getEmployees() method, wait for 500ms and if data was already returned you display them directly. If not data was returned so far you need to display the loading indicator. You will need an asynchrous call and callback here, so you probably want to have something like a separate class doing the synchronization here, but it probably will be worth the efford.

    I have implented something similar in .NET/C#, where an action is triggered only after 500ms of wait time if special other conditions are also true. When using the application the user will recognize a little bit delay in the reaction of the GUI, but it won’t disturb your overall look & feel.

    By the way, I like the approach to have only one getEmployees() method shown to your GUI. This way you make sure that you have a strict separation between GUI and application logic…

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

Sidebar

Related Questions

Let me explain best with an example. Say you have node class that can
Let's have an example like below: package xliiv.sandbox; import android.app.Activity; import android.os.Bundle; import android.util.Log;
Let's say that I have a SQLite database that I create in a separate
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
Let's say I have multiple requirements for a password. The first is that the
Let's say that I have a date in R and it's formatted as follows.
Let assume we have two activities. A - main activity, that is home launcher
Let's say you have a method that expects a numerical value as an argument.
Let's say I have a bunch of links that share a click event: <a
Let's suppose I have a Discussion model, and that a discussion can be tagged.

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.