Thursday 15 July 2010

c# - What is the difference between data validation and exception handling? -



c# - What is the difference between data validation and exception handling? -

my question, may pretty basic, want understand core difference between info validation , exception handling, , when should use both of them.

i told should never utilize exception handling in code unless absolutely have because exceptions complicate code. however, aren't try-catch-finally statements (exception handling) way separate business logic , ui? best practices when validating user input, , displaying error messages in ui?

data validation means checking info before performing operations fail, illustration check 0 before doing division.

exception handling means defined behavior if operation fail, illustration if database query times out.

how take between tow depends on doing. while not elegant utilize exception handling grab 0 devisor since can check before, have utilize exception handling on operations communicates other resources (database queries or tcp sockets fail, or disks go out of space).

c# error-handling separation-of-concerns

No comments:

Post a Comment