New answers tagged

7

Exception If your algorithm cannot find a date, it is easier to raise an Exception than to return ''. Returning sentinel values instead of exceptions can lead to unexpected behaviour if the user of this function does not test for this sentinel value. comments Comments should explain why you did something, not how. # Take the last four digits tells you ...


1

In my opinion the error handling is the smallest problem with this code. The main problem is that it's very unstructured and chaotic. Every single function is reading from (and worse, sometimes writing to) variables outside its scope. It's impossible to know which data a function is actually working with or what has changed after it has run. A function ...


2

I largely re-written the error handling functions. The reasons were multiple. Mostly, I needed greater flexibility, reliability and even a bit more general-purpose use. File func-color_support First, I created this separate file for defining colors and determining if terminal colors are supported: #!/bin/sh # do not warn that variables appear unused # ...


3

The Java issues are already described above, so let me add Eclipse-specific points. This code will handle exceptions as expected in the main thread only (and will throw InvalidThreadAccess otherwise). But it is not a good idea to work with I/O in the main thread as the user will be unhappy with a frozen UI. Showing dialogues from some operation is bad ...


3

Review Is there a better way to safely manage the cancellation and disposal of SemaphoreSlim instances? You've made a pattern to safely manage completing / aborting a task that is acquiring or has acquired a lock on a semaphore, not to safely manage the cancellation and disposal of SemaphoreSlim instances. You should only release the semaphore if you are ...


Top 50 recent answers are included