I have a basic API in progress, and all of my calls return error = false if successful. Basically it starts out ERROR = false and as it goes through code, does error checking. If the request was processed without errors, error will remain = false.
In my inexperienced opinion, do whatever makes sense. What is the function's name? If you were to say it in English (get Gerry on the line!), how would you state it? You hopefully wouldn't not say that its true condition of being false would be not false, correct?
I'm still working on my first application that actually does something useful. I don't really know where I'm going with this, but I have the main window start with this:
Code:
bool projectChanged = false;
Why this? Because it sounds correct. When is the last time someone said "your hair looks different. is it exactly the same as before?" Probably never. We ask if things changed, not if they stayed the same.
Then in a few places I have this:
Why? Because it sounds right.
At the end, I have an event:
Code:
private void MainWindow_Closed {
if (projectChanged == true) {
askSaveChanges();
}
}
In English, what does that line say? If the project changed, ask to save changes. It could just as effectively written sort of liike this:
Code:
if (documentChanged()) {
askSaveChanges();
}
Just speak it to understand it. Did the document change? If true, ask to save changes.
I think of a lot of writing would improve if people spoke what they were writing. Here's my favorite game critic reading hate mail exactly as it is written. Flaws jump out immediately when you try saying what was written.
https://www.youtube.com/watch?v=mv04aKBhZ9U
I have a remote function setup that checks to make sure a datasource is available.
It's called checkDSN
If the DSN is available it returns
{"error":false}
If the DSN is not available it returns
{"error":true}
IMO, checkDSN should be a positive confirmation. Did you check the DSN? Yes? Then let's keep going.
What's the alternative? "Yes I checked the DSN. It responded No." Huh? I'm always thinking in terms of "yes" meaning "do something".