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

  • Home
  • SEARCH
  • 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 563647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:40:57+00:00 2026-05-13T12:40:57+00:00

I’m working on creating a Javascript Tab library. Actually, it’s already been developed and

  • 0

I’m working on creating a Javascript Tab library. Actually, it’s already been developed and is working great. But it’s due for a rewrite to fix some underlying annoyances and quirks we’ve found while using it. Anyway, here’s the current model.

The current model has a TabSet object, which houses the main functions for the tab library: addTab, removeTab, showTab, hideTab, and related history functions. Then there is a Tab object that contains the data/methods related to the tab: showThrobber, hideThrobber, reload, and creating the actual DOM elements for the tab. Now, you can see this is a bit disjointed. TabSet handles showing a tab and hiding a tab and Tab handles reloading the tab.

Here’s the question: What is the best way to organize the methods for this tab library. The problem we are running in to is that the current model, while disjointed, makes sense. TabSet is indeed showing a tab, hiding a tab and removing a tab. But the Tab itself is indeed being shown, hidden and removed. Really, all the function make sense to be in either class: TabSet or Tab.

Let’s use an analogy. When someone needs to talk, everyone needs to stop talking. There are two ways for this to happen. 1) The leader (TabSet) tells everyone to stop talking and then tells the speaker to start talking. 2) The speaker tells everyone to shutup and starts talking. It makes sense to have the controller tell other Tabs to hide and tell the new Tab to show. But it also makes sense to have the Tab tell all the other Tabs to hide and then show itself.

What are your thoughts?

  • 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-13T12:40:57+00:00Added an answer on May 13, 2026 at 12:40 pm

    Personally, I’d design it so that a Tab only knows about itself and the TabSet that is managing it. It wouldn’t carry a reference to the other tabs.

    I’d put show() method on Tab; internally it would ask the TabSet to hide all other tabs and show itself.

    I’m assuming exactly one tab must be shown at all times, so there’s no point in having a public method to hide an individual tab.

    The idea behind that design is that you have less error checking to worry about. If your TabSet object had a showTab(tab) method, you’d have to check to make sure that the tab being passed in was actually one of the tabs in the set.

    Usually when I design an API my first priority is to make it hard or impossible to pass in invalid inputs.

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

Sidebar

Ask A Question

Stats

  • Questions 448k
  • Answers 448k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could use core animation to do that. Fade out… May 15, 2026 at 7:46 pm
  • Editorial Team
    Editorial Team added an answer More importantly, how do I get things to happen on… May 15, 2026 at 7:46 pm
  • Editorial Team
    Editorial Team added an answer Found out what the problem was. When Silverlight is embedded… May 15, 2026 at 7:46 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.