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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:34:32+00:00 2026-06-01T02:34:32+00:00

I hope this won’t sound like a stupid question. I have a class A

  • 0

I hope this won’t sound like a stupid question.

I have a class A and a class B. Now the only thing B has is a String ID.
Now I can have multiple objects A that each can have 0 or more objects of type B.
These are contained in a HashMap(ID,someData) each class A has.

What I want to do is each time I add a new ID in class A to check whether there already
is a on object of Type B with the same ID in any of the other class A objects I have, and if not, create a new B object.

Hope this makes sense. If what I ask is wrong is some way, please be kind enough to explain
how is this a bad practice or conceptualy wrong.

Thanks a lot.

EDIT:To be more clear,in my case, it is not desireable to share the HashMap(ID,someData) for all my objects as for example let’s say A is a Course class,Or Catalogue, or Bank etc. Each A class may share some students/clients but each A class may contain different class B objects.

  • 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-01T02:34:33+00:00Added an answer on June 1, 2026 at 2:34 am

    It’s not bad practice, it seems like you’re implementing the Instance Manager Pattern.

    • Ability to look up one or more instances (via a key) of the managed object(s). If only one managed object, then a key is not necessary.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I sure hope this won't be an already answered question or a stupid one.
This question may seem trivial, but I hope you won't ignore it. Before destroying
Hope this question is not stupid since I am an amateur web designer. I
First question on stackoverflow :) Hope I won't embarrass myself... I have a javascript
In C++ I have only seen this done by converting the string object into
I hope this question has an obvious answer to anyone who knows his way
I have a class, which has a boost::asio::io_service object. I want this object stored
It's my first question on SO, I hope this question won't be bad. I
I hope this is a simple question. If I have a UINavigationController and I
Hope this is not a dupe. I would like to be able to do

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.