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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:58:11+00:00 2026-05-27T09:58:11+00:00

This is a generic question, I don’t know if it belongs to Programming or

  • 0

This is a generic question, I don’t know if it belongs to Programming or StackOverflow.

I’m writing a litte simulation. Without going very deep into its details, consider that many kind of identities are involved. They correspond to Object since I’m using a OOP language.

  • There are Guys that inhabit the world simulated
  • There are Maps
  • A map has many Lots, that are pieces of land with some characteristics
  • There are Tribes (guys belong to tribes)
  • There is a generic class called Position to locate the elements
  • There are Bots in control of tribes that move guys around
  • There is a World that represents the world simulated

and so on.

If the simulated world was laid down as a database, the objects would be tables with lots of references, but in memory I have to use a different strategy. So, for example, a Tribe has an array of Guys as a property, The world has a, array of Bots, of Tribes, of Maps. A Map has a Dictionary whose key is a Position and whose value is a Lot. A Guy has a Position that is where he stands.

The way I lay down such connections is pretty much arbitrary. For example, I could have an array of Guys in the World, or an Array of guys per Lot (the guys standing on a piece of land), or an array of Guys per Bot (with the Guys controlled by the bot).

Doing so, I also have to pass around a lot of objects. For example, a Bot must have informations about the Map and opponent Guys to decide how to move its Guys.

As said, in a database I’d have a Guys table connected to the Lots table (indicating its position), to the Tribe table (indicating which Tribe it belongs to) and so it would also be easy to query “All the guys in Position [1, 5]”. “All the Guys of Tribe 123”. “All the Guys controlled by Bot B standing on the Lot b34 not belonging to the Tribe 456” and so on.

I’ve worked with APIs where to get the simplest information you had to make an instance of the CustomerContextCollection and pass it to CustomerQueryFactory to get back a CustomerInPlaceQuery to… When people criticize OOP and cite verbose abstractions that soon smell ridiculous, that’s what I mean. I want to avoid such things and having to relay on deep abstractions and (anti pattern) abstract contexts.

The question is: what is the preferred, clean way to manage entities and collections of entities that are deeply linked in multiple ways?

  • 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-27T09:58:12+00:00Added an answer on May 27, 2026 at 9:58 am

    It depends on your definition of “clean”. In my case, I define clean as: I can implement desired behavior in an obvious, efficient manner.

    Building OOP software is not a data modeling exercise. I’d suggest stepping back a little. What does each one of those objects actually do? What methods are you going to implement?

    Just because “guys are in a lot” doesn’t mean that the lot object needs a collection of guys; it only needs one if there are operations on a lot that affect all the guys in it. And even then, it doesn’t necessarily need a collection of guys – it needs a way to get the guys in the lot. This may be an internally stored collection, but it could also be a simple method that calls back into the world to find guys matching a criteria. The implementation of that lookup should be transparent to anyone.

    From the tenor of your questions, it seems like you’re thinking of this from a “how do I generate reports” perspective. Step back and think of the behaviors you’re trying to implement first.

    Another thing I find extremely valuable is to differentiate between Entities and Values. Entities are objects where identity matters – you may have two guys, both named “Chris”, but they are two different objects and remain distinct despite having the same “key”. Values, on the other hand, act like ints. From your above list, Position sounds a lot like a value – Position(0,0) is Position(0,0) regardless of which chunk of memory (identity) those bits are stored in. The distinction has a bit effect on how you compare and store values vs. entities. For example, your Guy objects (entities) would store their Position as a simple member variable.

    I’ve found a great reference for how to think about such things is Eric Evan’s “Domain Driven Design” book. He’s focused on business systems, but the discussions are very valuable for how you think about building OO systems in general I’ve found.

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

Sidebar

Related Questions

I tried to phrase this as a generic question but realized I don't know
I know this is a very generic and subjective question, so feel free to
This is a very generic 'best practice' question, but here's an example. Let's say
I know this question has been asked here before, but I don't think those
This is a generic question that applies to (probably) any high-level programming language. Here
This is kind of more generic question, isn't language-specific. More about idea and algorithm
So this is more of a generic question. I seem to keep finding myself
This may be a generic OOP question. I wanted to do a generic comparison
This is a question about generic c++ event driven applications design. Lets assume that
This is more of an generic XML Schema question, but if and how 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.