3 ms·
> Where is this—possibly wrong—assumption documented? Presumably in the compiler documentation. Although the assumption was made merely to ensure that we under
by randomdata 4y ago
> Where is this—possibly wrong—assumption documented?
Presumably in the compiler documentation. Although the assumption was made merely to ensure that we understood that each algorithm choice was functionally equivalent, to continue in the theme of discussion.
> which may or may not hold in the future?
Totally fair. Let's say your choice, which was fine at the time of choosing, with a later compiler update does get optimized in a new way that that longer satisfy your application's requirements. How do you plan to keep up with that if you don't have automated tests to prove whether or not your code still operates within your expectations?
> But you given up already on this line of argumentation anyway, I see ;-)
No, but I was still working on getting a concrete example in which we can build a test or two for to provide a demonstration. Unfortunately, the vague sorting suggestion still isn't concrete. What are you sorting? Which algorithm did you choose and why? I had hoped that if I rephrased the question you would feel more comfortable coming out of your shell, but I can see your worry remains. Back in my day education was something to get excited about so I struggle to understand, but recognizing your uncomfortableness now I'll not needle you further and apologize for not seeing it sooner.
- still_grokking 4y agoYou're distracting form the main topic, which is: > How does a test inform you why a function was implemented using algorithm A and not algorithm B which would also do the same? You made up than a straw man saying something something that you assume that both algos get optimized to the same machine code. Which is completely irrelevant to the actual question. I've only mentioned that both algos need to have the same big-O characteristic obviously as otherwise they wouldn't be interchangeable in the first place. > What are you sorting? Which algorithm did you choose and why? LOL, that's exactly the question a good code comments should answer. Because code can't do that! The example here is: Big-O is one thing, but "what are you sorting" matters, and some algo may be better suited for the task than the other. If this isn't obvious it needs to be documented. The best place to do that is right where the code is. As only this will make sure it will be read together with the code. (Otherwise someone could for example rewrite the code to something "more standard" and it's not a given that the people reviewing the change would know about the reasoning behind the original implementation; a comment would have prevented bugs and regressions in such a case). Thanks for proving my point… :-)