|
|
|
|
|
by kabdib
4299 days ago
|
|
One rule of thumb I use for code is: Can you step through it in a debugger, at the source level, and have insight into what is going on? Because with really, um, "clever" code, you'll probably need to. And so will your cow-orkers. And if the code doesn't work or has limitations -- quite likely with creeping "clever" machinations like this one -- you'll get Spoken To. (Yeah, this depends on how good your debugger is. Visual Studio and XCode are pretty decent). |
|
And for whatever reason, C++ debuggers and debug info formats don't seem to be doing a great job of keeping up with the language. Even basic stuff like nested function calls (as easily found with any smart pointer/iterator or array class...) tends not to work very well, to say nothing of single stepping in to std::function, or watching STL types, or using iterators or smart pointers in the watch window. So this necessarily means being a bit conservative about which features you use.
(You might have to go through the shipping-a-product process a couple of times before you really internalize this. But once you've learned it, it really does stick.)