|Keep It Simple, Stupid|
Re: Best Practices for Exception Handlingby jonadab (Parson)
|on Jan 30, 2003 at 04:53 UTC||Need Help??|
> If I have a GUI (A) which issues a message to some object (B) which
> in turn sends a message requesting data from object (C), what
> happens if C determines that the data is bad due to user input
See, that's where I always get lost. If C is getting user input, and the user input is invalid, C should just reget the user input. When it has valid input, it should pass that back to B. Otherwise, it should continue to ask the user to fix up the input.
In a slightly different scenerio, C might think the input is okay (there's an integer in this integer field, and some text in this required text field; C does not know the meaning of these data, but they are the kind of data that were requested), but B might discover that it's inconsistent. (There is no thirty-first of February.) In that case, B would possibly explain the problem to the user and then call C again; only when the input is good enough for B to do its job does it then pass the result back to A.
Do you see where I'm getting hung up? It's not with the question of HOW to pass stuff back to the parent (which was the original topic of the thread, I know), but more with the more basic question of why that is a thing that needs to be done. That's the point I haven't managed to understand yet.