4 ms·
In my previous life I was maintaining some backend services. One of the most common reasons for a service dying was a typo in a name in some rarely visited code
by avian 11y ago
In my previous life I was maintaining some backend services. One of the most common reasons for a service dying was a typo in a name in some rarely visited code path. I was tempted to write a similar module that would be a little bit smarter: when some identifier (variable, method, etc.) was not found, instead of raising an exception, try to find a similarly named thing and use that instead. I never did find a good way of implementing that.
- insertnickname 11y agoThat's probably for the best.
- vlunkr 11y agoSeriously, that's asking for unpredictable behavior. Maybe if it printed the suggestion to the logs and then failed it would be ok.
- insertnickname 11y agoYes, it's crazy. I saw a Python library a while ago that when would pip install any missing module, even if it's because of a typo. Crazy.
- ChicagoBoy11 11y agoI spilled tea because of laughter induced by your comment. well done.
- kelvin0 11y agoHow about better testing and path coverage of your code? I hope that was also explored as a way to stabilize your codebase? Otherwise your suggestion does come offa bit as 'cowboy-ish' to say the least ...
- HCIdivision17 11y agoI think you might like something like TheFuck? EDIT: This bash commandline completion has been updated to by default wait for the user to verify the replacement command is what they wanted; this pretty much turns this from a terminal Russian Roulette into a kinda handy autosuggestion! https://github.com/nvbn/thefuck https://github.com/nvbn/thefuck (Previous discussion: https://news.ycombinator.com/item?id=9396116 https://news.ycombinator.com/item?id=9396116 )
- dgcoffman 11y agoRuby has a language feature for this and it's pure 100% poison. http://rubylearning.com/satishtalim/ruby_method_missing.html http://rubylearning.com/satishtalim/ruby_method_missing.html
- riffraff 11y agothat is neither what OP mentioned (automatic matching of a typo) nor poison. Also, it's from Smalltalk, and found in some ways also in python, objective-c and many others.
- pekk 11y agoThat came from Smalltalk, where it was named doesNotUnderstand. It's always difficult to choose between crippling the language and encouraging stupidity.