hex337 / quantum-attendance

An attendance program for Quantum Martial Arts
MIT License
3 stars 2 forks source link

Merge the top level redux stores #25

Closed hex337 closed 7 years ago

hex337 commented 7 years ago

Addresses #24

mlamina commented 7 years ago

I'm still a bit confused about the "reducers" and what "normalized data" is in this context - could you comment on that?

hex337 commented 7 years ago

So, the best way to describe it is to look at the reducer test. We get a blob of information when we request student information, which includes the belt object. But 10 student objects can share the same belt object, and we don't want to store that belt object 10 times. Instead, we just store the id in the belt field, and store a separate entity for belts, where the id is an index and you can pull that information out.

It's essentially taking what we get from the API and turning that into a relational key value store.

mlamina commented 7 years ago

Why not just keep the data structure as it is? It feels like we're introducing complexity without gaining any value.

hex337 commented 7 years ago

Since we don't have direct access to the database, this is a more efficient way to store the data without dealing with multiple levels of nesting. An example is a student belongs to 0 or more classes, and a class has many students. If you wanted to represent that in a structured json object, you'd potentially have a infinite loop or a pretty deeply nested object. If one of the sub objects changes, say a student in a class that another student attended, you would have to update all nested instances of that object. It would be better to just refer to that instance of a student by an id and then fetch the data when you need it. If that student's data gets updated, then it will get reflected everywhere.

mlamina commented 7 years ago

OK I think I don't have enough React experience :) I found some more log statements, besides that I didn't see anything else!