3 ms·
Many times I've seen that it's been out of a genuine desire to solve the asker's problem, but the asker has already started down the wrong path and is determine
by Zikes 11y ago
Many times I've seen that it's been out of a genuine desire to solve the asker's problem, but the asker has already started down the wrong path and is determined to see it through.
A recent example: someone was using a map/hash object to store a series of documents, and needed a way to extract N items from the map for pagination reasons. They presented a for loop but said that something "felt wrong" about that. Many of the comments were about how maps had no guarantees about order, and that each attempt to grab a "page" of objects would result in a random set, meaning pages 1, 2, and 3 could all conceivably have common items, rendering pagination fundamentally broken.
There were several suggestions to use an ordered array of map keys, but the asker was determined, stating "it's just for testing purposes, order doesn't matter, I should never have mentioned pagination".
Maybe there's an important detail that the asker left out, but by all accounts they were given sound advice and even working examples, but they still seemed frustrated and would likely describe the experience as "alienating".
- collyw 11y agoIts not always the wrong path, but the only path available to you if you have a complex system. You could do as the alternatives suggest, but you know that will affect some other part of your system. The reasons for needing a particular soluition aren't always available without more context.
- Zikes 11y agoWithout having an ordered array of keys there's just no safe way to paginate a map. The map's own documentation says that key order has no guarantees, making it effectively random. It really is a silo'd issue, I can't even imagine what other factor could change the above facts without resorting to unsafe memory access.