3 ms·
Your "Get" method hides complexity. It could be that it loops over a list, or that it hashes to find the bin, then loops over the list of items in the bin, or a
by khedoros1 9y ago
Your "Get" method hides complexity. It could be that it loops over a list, or that it hashes to find the bin, then loops over the list of items in the bin, or any of other dozens of other possible implementations.
So the next question is "What's the implementation of the Get(key) method?" Or maybe "Why aren't you using your language's library methods to loop over that list?"
- smegel 9y agoWhy are you even asking the question if profiling hasn't determined a performance problem in that bit of code?
- khedoros1 9y agoI'm considering cases where looping over a list mean using a simpler algorithm than whatever's provided by "Get", applying rules #3+#4, after determining that "Get" is a bottleneck.
- deleted 9y ago[deleted]
- parenthephobia 9y agoIs this really an explanation of why manually iterating over a list is simpler than just calling a method? Get is simpler precisely because it hides the complexity. > Or maybe "Why aren't you using your language's library methods to loop over that list?" What makes those methods not subject to the "hiding complexity" objection?
- khedoros1 9y agoIt's an ill-considered stream of consciousness where I wasn't clearly separating "simplicity of interface" from "simplicity of implementation". Part of what I was going for is that a clean interface might hide a complex implementation. If you've followed rule 1 and see that "Get" is a bottleneck, it makes sense to apply rules 3+4, and see if there isn't a simpler implementation than the one provided by "Get".