9 Replies - 349 Views - Last Post: 25 January 2018 - 09:45 PM

#1 bb8  Icon User is offline

  • D.I.C Regular

Reputation: 7
  • View blog
  • Posts: 325
  • Joined: 31-January 16

sequence of command validation and work

Posted 25 January 2018 - 10:52 AM

i don't know if this is the proper forum to post this question but please bear with me.

so in my application i have a dialog which has two vertically arranged line edits, each of which can get a list of values. values for first line edit are mandatory, and for the second one they aren't, i.e. second one can be left empty.

first i retrieve the value(s) of my 1st line edit, and process them. for processing i have commands which first validate() the values, then, if the validation was successful, an execute() method is called to do work based on these values, after which a "success" message is printed. if the validation isn't successful, an "error" message is printed.
then i check if second line edit is empty, i just return. if it's not, i do the same validation and execution steps for those values. simple.

now imagine a situation where values in first line edit and valid, and in the second one - they aren't. my code will process (validate() and execute()) first values, and issue a validation error on second ones.

this is not a desired behavior. what i need is, if the seconds line edit's values aren't valid, i shouldn't process the first values.

one solution is to exchange places of line edits, but the bad thing here is that it won't be logically correct (2nd values should come after 1st ones).
another solution i thought of is, before validating and executing 1st values, validate the 2nd values (if any are present) and if they aren't valid, just return. then (if 2nd values are valid), validate and execute 1st values, and if everything is okay, execute
work for 2nd values, which is really not a good solution.

any good idea? thanks in advance

Is This A Good Question/Topic? 0
  • +

Replies To: sequence of command validation and work

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13765
  • View blog
  • Posts: 54,941
  • Joined: 12-June 08

Re: sequence of command validation and work

Posted 25 January 2018 - 10:55 AM

Quote

i don't know if this is the proper forum to post this question but please bear with me.

Is it for a game?
Was This Post Helpful? 0
  • +
  • -

#3 bb8  Icon User is offline

  • D.I.C Regular

Reputation: 7
  • View blog
  • Posts: 325
  • Joined: 31-January 16

Re: sequence of command validation and work

Posted 25 January 2018 - 11:28 AM

well what i meant was, i think here most people ask about code (implementation) related things but this one is like a logical thing (well, code is all logic but i wasn't asking for implementation details)
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13765
  • View blog
  • Posts: 54,941
  • Joined: 12-June 08

Re: sequence of command validation and work

Posted 25 January 2018 - 12:43 PM

If it's not a game then most likely game dev isn't probably the best. I'll move it to 'software dev'.
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is offline

  • blow up my boots
  • member icon

Reputation: 6500
  • View blog
  • Posts: 26,287
  • Joined: 12-December 12

Re: sequence of command validation and work

Posted 25 January 2018 - 12:58 PM

I don't follow. If the two sets of values are related, and should not be processed in isolation, then check them both before doing any processing. Otherwise, explain why this isn't appropriate.
Was This Post Helpful? 0
  • +
  • -

#6 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 6010
  • View blog
  • Posts: 20,667
  • Joined: 05-May 12

Re: sequence of command validation and work

Posted 25 January 2018 - 03:35 PM

View Postbb8, on 25 January 2018 - 12:52 PM, said:

another solution i thought of is, before validating and executing 1st values, validate the 2nd values (if any are present) and if they aren't valid, just return. then (if 2nd values are valid), validate and execute 1st values, and if everything is okay, execute
work for 2nd values, which is really not a good solution.

Why exactly is this not a good solution? It's not like validation is a destructive operation? Or is it? Does your validation create side effects?

In general, good UI and software design has the following sequence:
- user enters values into a form or dialog
- when the user submits the form or closes the dialog, the software tries to validate the values in the UI
- if there are problems, the user presented with the UI again
- if there are no problems, then the values entered in the UI are processed
Was This Post Helpful? 0
  • +
  • -

#7 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 6010
  • View blog
  • Posts: 20,667
  • Joined: 05-May 12

Re: sequence of command validation and work

Posted 25 January 2018 - 03:44 PM

With Web 2.0, as well as iOS and Android latest phone UI design decisions, things start to get murky because people are starting to be conditioned to the idea that there is no "submit" or "ok" button. Things "just happen". It's not always clear exactly when it happens.
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13765
  • View blog
  • Posts: 54,941
  • Joined: 12-June 08

Re: sequence of command validation and work

Posted 25 January 2018 - 03:47 PM

No kidding.. half the time trying to get a straight answer of what the heck just happened feels way to uncertain to make me happy.

Posted Image

.. or I start updating the whiteboard with epsilon transitions and doom it all to hell.
Was This Post Helpful? 0
  • +
  • -

#9 snoopy11  Icon User is online

  • Engineering ● Software
  • member icon

Reputation: 1437
  • View blog
  • Posts: 4,626
  • Joined: 20-March 10

Re: sequence of command validation and work

Posted 25 January 2018 - 05:53 PM

Hmm,

two vertically aligned edits ??

why not use combo boxes and a drop down list ?

first combo box selection determines what values populate the second drop down.. so user cannot select an invalid value.
Was This Post Helpful? 0
  • +
  • -

#10 bb8  Icon User is offline

  • D.I.C Regular

Reputation: 7
  • View blog
  • Posts: 325
  • Joined: 31-January 16

Re: sequence of command validation and work

Posted 25 January 2018 - 09:45 PM

thanks for the answers.

the reason why i have to process the values in isolation is because for i make a call to a command by its name, which is basically meaning "go get the command pointer from registry and call its validate() and if successful, execute() methods"

why isn't that one a good solution? well, validate() is a public method and i can practically get the command from registry and call the validate() on it, then set some flag that "the validation has been done" so when the actual command call occurs (that is, after i've processed the first values), no extra validation will be done for second values. this is not good cause i'm breaking command execution normal sequence.

it's not that first line edit determines what values populate the second one, but rather: if the second values aren't valid, don't process the first ones.

EDIT
: well, i guess i was just complicating things too much, trying to look for a better solution. i'll go with that one, anyways. a fellow guy advised that too.

EDIT OF EDIT: even better :D when i validate second values before first ones, if an invalid value is specified, i call the command with the second values as parameter so that everything that follows an unsuccessful validation, will happen!

This post has been edited by bb8: 26 January 2018 - 03:29 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1