design - Limiting a value in a user form input -


say if have text box input user key in value.

this value passed function, say:

f(x,y) = x / y; 

where x,y user inputs.

in case, if y == 0, divide 0 error occur.

my question practice, section of code should responsible error checking? it

1) read text box value, automatically change value else if equal 0.

or

2) when 0 passed function f(x,y), within function, handle potential divide 0 error.

you want errors apply (such divide 0 error) caught function itself. don't want use function in different part , need rewrite same error checking (or worse, forget to).


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -