L
Lars-Otto Nymoen
Hi!
I was hoping someone here could give me some help on how to handle
input validation in a Swing application. The structure (layering) of
the app is something like this: SwingForm --> DataAccessObject -->
Database
My main question is where to put the validation code. Two scenarios
come to mind:
1. Let the DataAccessObject handle the validation, an throw an
exception when it fails. The exception would be caught by the
SwingForm which then gives the user a response.
2. Let the SwingForm itself handle the validation without the use of
exceptions.
So the bottom line is: who should be responsible of handling the
validation. I think scenario 1 seems like a good aproach, but I'm not
sure it's "correct" to handle form validation as exceptions. Bear in
mind that I'm quite new at Java programming, so if you have other
scenarios please let me know.
I was hoping someone here could give me some help on how to handle
input validation in a Swing application. The structure (layering) of
the app is something like this: SwingForm --> DataAccessObject -->
Database
My main question is where to put the validation code. Two scenarios
come to mind:
1. Let the DataAccessObject handle the validation, an throw an
exception when it fails. The exception would be caught by the
SwingForm which then gives the user a response.
2. Let the SwingForm itself handle the validation without the use of
exceptions.
So the bottom line is: who should be responsible of handling the
validation. I think scenario 1 seems like a good aproach, but I'm not
sure it's "correct" to handle form validation as exceptions. Bear in
mind that I'm quite new at Java programming, so if you have other
scenarios please let me know.