So recently I have been working with a large-scale app that has a large number of individual objects with specific group attributes. For example, I have a list with objects such as

{Name: "Todd", Desc: "Todd likes basketball", Team: "#23"}

This list is has about 10k of these objects in it with about 1,000 different obj.Team values, ranging from Team: #1 -> Team: #1000.Throughout my app, I will be using the full list of objects for certain calculations as well as just viewing all objects with a certain obj.Team value.

I will be using a Redux State w/ React to store these values and I was wondering what the best method would be in terms of performance, better practice, readability, etc. Would it be preferably to have two lists where one list is the full 10k objects while another list is a list of lists based on the Team value, where the same obj data is copied to two lists (with just different format)? Or would it be best to simply have a single list of these 10k objects and when I want to use some calculation on a specific obj.Team value, I just loop through and find the appropriate objects?

1 Answer 1


References are wonderful things. If you really need something to be an object, and to be available in two locations, then consider passing references to that one object to those two locations.

Do this and you don’t have to search though a list to find it because you never lose it. You keep track of it somewhere else as well.

At first people feel reluctant to do things like this because their afraid that they’re wasting space but regardless of how big the object is, a reference is only 64 bits. Using a bit of space can save some time and make code easier to understand.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.