If you're just going to sit there doing nothing, at least do nothing correctly
201–210 of 356 posts
Re: If you're just going to sit there doing nothing, at least do nothing correctly
#202I've learned this as "swallowing errors" and IMO it's a poor practice. Not only does it not solve the issue at hand (you cannot print on an xbox), but it actively hides how broken the software is, which makes bug discovery and testing much harder. This is one thing I like about Go's panic. You're mostly not supposed to use it or recover from it at run time. It serves as a great vehicle to blare loud sirens at testing…
The article isn't so much about swallowing exceptions, but more about designing the system so you don't have to raise exceptions.
Re: If you're just going to sit there doing nothing, at least do nothing correctly
#203I missing what the magic is here. This seems like a long way to go for “we know that this device is an Xbox and Xbox doesn’t support printing, let’s tell the user” Only it doesn’t tell the user. It leads them down a path implying implementation is possible. On the other hand, I now know why so many issues I’ve troubleshooted on MS products end in tears and complete confusion as to why they wouldn’t just say “this is…
You're missing the fact that Xbox can run apps developed for (desktop) Windows, and that the scenario in the article is about the platform end user relationship and does not involve the app developer at all.
Re: If you're just going to sit there doing nothing, at least do nothing correctly
#204I'm sorry but that code sample is an incomprehensible eyesore. And I've written PHP4.
Re: If you're just going to sit there doing nothing, at least do nothing correctly
#205I've learned this as "swallowing errors" and IMO it's a poor practice. Not only does it not solve the issue at hand (you cannot print on an xbox), but it actively hides how broken the software is, which makes bug discovery and testing much harder. This is one thing I like about Go's panic. You're mostly not supposed to use it or recover from it at run time. It serves as a great vehicle to blare loud sirens at testing…
It has irked me for decades that when the internet connection fails, all you get is a message that it failed. But what failed? 1. the software on your computer 2. the computer's hardware 3. the ethernet cable or wifi 4. the switch 5. the router 6. the cable modem 7. the internet cable to your house 8. the ISP 9. the remote system you're trying to connect to Nothing has improved for decades.
Re: If you're just going to sit there doing nothing, at least do nothing correctly
#206Earlier quoted context omitted.
So what's your solution then? Break all apps simultaneously that do not have extensive tests for gracefully handling cases that were impossible when they were created? This is not weird "hidden state" on the implementer's side. It's a straightforward dummy API and all you need to do to test it are a few straightforward asserts that it returns the correct dummy values and doesn't crash. > I have a feeling that "soluti…
> So what's your solution then? Break all apps simultaneously that do not have extensive tests No test required. Just try... catch. > for gracefully handling cases that were impossible when they were created? You can never know they are impossible. That is why you have a top-level try...catch.
That doesn't even make any sense. Where on earth would you insert a try...catch?
So many people commenting on this article seem to have fundamentally misunderstood what the situation/scenario even is, which is made more jarring by the fact that so many others seem to have gotten it just fine.
Re: If you're just going to sit there doing nothing, at least do nothing correctly
#207As the author is a Microsoft employee I'm a little surprised no attribution or reference to the original author of (the levels of) exception safety guarantees which his article partly describes.
Raymond Chen (article author) is refering to the "no throw guarantee" in his article as opposed to one of the other outcomes https://en.m.wikipedia.org/wiki/Exception_safety
Re: If you're just going to sit there doing nothing, at least do nothing correctly
#208Wrong, errors should not go unnoticed, let alone helping them to propagate. Cascading effects should be kept on a short leash. System takes one step in the wrong direction, kill it. The two most miserable things are, things not happening and there's no feedback on why, and, the other extreme, when things are overengineered and no one can predict where problems might cascade to.
Re: If you're just going to sit there doing nothing, at least do nothing correctly
#209Wrong, errors should not go unnoticed, let alone helping them to propagate. Cascading effects should be kept on a short leash. System takes one step in the wrong direction, kill it. The two most miserable things are, things not happening and there's no feedback on why, and, the other extreme, when things are overengineered and no one can predict where problems might cascade to.
lord grant me the confidence of someone who reads a thoughtful explanation of a problem and its solution by Raymond Chen and responds with "Wrong, "
Re: If you're just going to sit there doing nothing, at least do nothing correctly
#210I'm sorry but that code sample is an incomprehensible eyesore. And I've written PHP4.
Stripping out the Windows types and compile-time validation and the wrappers, and picking non-Windows error codes, you can turn the code into more Unix-like C++:
int32_t CreateWidget(int32_t* widget)
{
*widget = nullptr;
return ECANCELED;
}
int32_t GetWidgetAliases(wchar_t* aliases, uint16_t capacity, uint16_t* actual)
{
*actual = 0;
return EBADF;
}
int32_t EnableWidget(int32_t widget, bool value)
{
return EBADF;
}
int32_t Close(int32_t widget)
{
return EBADF;
}
However, this code may not function if you're building for 32-bit Windows and it may not work on every compiler; it just assumes certain bit sizes that the API only guarantees in the form of typedefs.