3 ms·
What's wrong with flat data? Why is nested data better than flat data? If you think about it, there's really nothing wrong with either. The only reason you wou
by nendroid 6y ago
What's wrong with flat data? Why is nested data better than flat data? If you think about it, there's really nothing wrong with either.
The only reason you would want to structure your data like that is if you want to think about the Box as a whole from a more abstract level.
But there's nothing wrong with writing an entire app that focuses on the measurement of the left bottom side of a box. If that's the requirement, than there's no need to define the measurement as part of a higher order type "Box" if you're not doing anything with the other measurements.
- alfonsodev 6y agoNothing wrong perse, but talking about readability, we see the world in categories and we communicate abstractions in words, I didn't say flat data is wrong, but that word in particular being too long smells like a bit of structure is needed, just to add another dimension to consider, which is how we abstract things in the world and model them in software matters.
- nendroid 6y agoBut if the structure is unused and my program only deals with a single integer does it make sense to modify the structure of the program for readability? No. If my program only modifies the left bottom side of the box it doesn't need the whole box defined. In this case and many cases similar to this, it's totally fine encoding more verbosity into the naming of the integer. The "smell" your sensing here is only called a smell because you can't logically explain it. Your brain is firing off a false alarm. I can easily make a variable name that can trigger the false alarm but you won't be able to come up with a reasonable nested structure to contain it. theColorOfTheSkyOnAThursdayAt6PM = "ReddishOrange" What are you gonna do here? I have a string that represents a color of the sky at a certain day on a certain time. What structure can reasonably contain this concept and ONLY this concept. Unless you want to define a structure called Sky the long name is the only possibility.
- alfonsodev 6y agoIs all context, if you have such specific need probably the app context is already understood and there is no need to have such big names, perhaps the apps is called, 'colors of Thursday 6pm' the you just hold a variable for sky. Same for box side, if your app only deals with a side, then is boxSide, you wouldn't say upperBottleTap, because all bottles have the tap on the upper side, and there is only one, so context is everything.