Neil Pate Posted December 13, 2016 Report Share Posted December 13, 2016 I have flip-flopped with this issue for like forever. Say I have a simple dialogue that can be cancelled by the user, is it more sensible to return the cancelled status or the ok status? I have always done it by returning a Cancelled status, I am just curious as to what others think is sensible. Quote Link to comment
Tim_S Posted December 13, 2016 Report Share Posted December 13, 2016 The NI code seems to use the convention of having a Canceled output. Seems that following the same convention would have less confusion. (From a practical standpoint, that is.) Quote Link to comment
ned Posted December 13, 2016 Report Share Posted December 13, 2016 Depends a bit on your dialog. For example, if your dialog allows you to close the window (using the typical X) in addition to having Cancel and OK buttons, I would return the OK status, so that it's clear that closing the dialog and hitting the Cancel button both have the same effect. Quote Link to comment
eberaud Posted December 13, 2016 Report Share Posted December 13, 2016 I second Ned's comment. Moreover I find that most developers naturally associate "True" to "OK" in their minds. But to be fair, my code is probably a 50/50 mix... The most important is to label the indicator such that it is self-explanatory. Quote Link to comment
infinitenothing Posted December 13, 2016 Report Share Posted December 13, 2016 OK=True seems more failsafe because if you do something stupid like have a zero itteration for loop it'll output false and usually doing nothing is safer. Quote Link to comment
hooovahh Posted December 13, 2016 Report Share Posted December 13, 2016 I have used both. Â Sometimes "Canceled" and some times "Valid Data". Â I hadn't really thought about it but I'd say the majority of the time that the data isn't valid, an error will be returned of some kind. Quote Link to comment
PiDi Posted December 13, 2016 Report Share Posted December 13, 2016 If the dialog has only "Cancel" button (e.g. processing something with possibility to abort), I'd go with Cancelled output, because that's really the only action the user can do. If it has "Cancel" and "OK" buttons, I'd go with OK output - positive logic is generally easier to grasp when you analyze the code. However, this really depends on the context. And you can also ouput enum with "Cancel" and "OK" elements. Quote Link to comment
smithd Posted December 14, 2016 Report Share Posted December 14, 2016 (edited) On 12/13/2016 at 3:40 AM, Neil Pate said: I have flip-flopped with this issue for like forever. Say I have a simple dialogue that can be cancelled by the user, is it more sensible to return the cancelled status or the ok status? I have always done it by returning a Cancelled status, I am just curious as to what others think is sensible. You could also return an error 43! The way I see it is that (a) positive logic is good and (b) there is only ever 1 good path (user enters values and presses OK) and depending on your dialog 1->N bad paths (cancel, hitting close, the dialog talks to something else and actually genuinely had an error, etc).* Edited December 15, 2016 by smithd Quote Link to comment
Neil Pate Posted December 15, 2016 Author Report Share Posted December 15, 2016 Thanks. I think I am mostly on the same page as everybody here. Quote Link to comment
ShaunR Posted December 15, 2016 Report Share Posted December 15, 2016 On 13/12/2016 at 11:40 AM, Neil Pate said: is it more sensible to return the cancelled status or the ok status? it doesn't matter. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.