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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:38:20+00:00 2026-06-01T12:38:20+00:00

I have part objects and material objects. Each part has at most 1 material

  • 0

I have “part” objects and “material” objects. Each part has at most 1 material assigned to it. Each material is assigned to 0 or more parts. It’s a DAG with 2 levels.

Should each part object have a reference to its material? Or would it be better to just store the material name or index. Or is there another way besides a database?

The first way means multiple references to the same material object, which seems bad, but how bad?

The second way seems ugly because numerical indices may not get updated correctly, or if referencing materials by name it requires string comparisons. It’s also reinventing object references that are already available in the language.

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

    Go with the reference. It’s quick and uses little memory and you’ll need it. (I do assume you’ll actually use it. A different or additional option would be to keep a list of parts references for each material. But don’t do this if you don’t need it.)

    Storing the material name or index will use more space and cost you a lot more when you try to get hold of the material’s object. In fact, the cheapest way to get a part’s material’s name is to use a reference to get the material and get the name or index from the material.

    Don’t use names and indexes internally in your program. They do have to be used (and stored in your program) to get things from databases and other programs. (“Other programs”, in practice, means sockets and such and flat files–originally the data came from another program or another session of this program.) And you do have to maintain your references: if the material is removed, all references to it have to be changed. Or you could mark the material as deleted (works well with garbage collection, but watch for re-adds).

    And to contradict myself: I have used names instead of references on rare occasion because they work well when materials (to use your case as an example) are being continually added and deleted. If I identify something as “Lumber”, a material of that name can be deleted and added 100 times without, at the end of the day, affecting my parts’ usage of it.

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

Sidebar

Related Questions

I have an object that has a multi-part key and I am struggling to
I have an application that uses Hibernate for its domain objects. One part of
I have an object in C# with lets say 20 properties and it's part
Let's say i have a griffon object that needs to be part of the
Why GetHashCode is part of the Object class? Only small part of the objects
I have some objects which I draw onto a Canvas as part of a
I have a requirement to create some NSDecimalNumber objects objects as part of my
I have a Transactions object (as a part of a shopping cart) that belongs_to
I have imported movieclip on my stage. But this movieclip has objects which lay
i have part of Asp.NET 1.1 project. I work with remote site, which works

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.