File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Are validations needed on the frontend GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Professional Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "Are validations needed on the frontend GUI " Watch "Are validations needed on the frontend GUI " New topic
Author

Are validations needed on the frontend GUI

Mxolisi Veco
Ranch Hand

Joined: Jan 14, 2010
Posts: 59
Good day all.

When URLBird users capture wrong data such as a rate $ XX in the search GUI when searching for rooms, the DBMain class will not find any data. Also searching does not change the database. So I am thinking there is no need for me to add any validations on the search GUI.

However, on the booking window, the client ID must be numerics and must have length 8. So I Have added validations to ensure that this is the user is forced to capture a client ID that meets this creteria.

I was just wondering the approach I have taken is the right one.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 3740

Hi Mxolisi,

Validations are not a must requirement, so not needed in the GUI. But of course your program must be able to handle every situation and don't crash. I ended up with a very restrictive GUI, so everything is validated, buttons are disabled when not applicable,...
You should certainly have validations in your business service (or Data class) to provide data integrity. A customer id "abcd" must not be written to data file. You may validate this in your client GUI, but you must validate this number on a higher level (to force data integrity).

Kind regards,
Roel

This message was edited 1 time. Last update was at by Roel De Nijs



SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Mxolisi Veco
Ranch Hand

Joined: Jan 14, 2010
Posts: 59
Thanks Roel.

I will add the valaditions on my Data class.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 3740

Mxolisi Veco wrote:I will add the valaditions on my Data class.
I wouldn't do that, because your Data class will be tied to this rooms data file and will be completely useless for reuse (for other data files). My Data class contains only validation against the (dynamically read) database schema.

Kind regards,
Roel
Mxolisi Veco
Ranch Hand

Joined: Jan 14, 2010
Posts: 59
Good day Roel.

I am not clear on what you are saying.

I have created a public class Validator that has public static methods. Each of these methods validates a certain field on the record.

When public void create(String[] data) or update is called, I call the methods in Validator class to validate each of the data[] fields. This makes sure that the data being put into the system is always in the right format.

Because everything that goes into the system is always in the right format, there is no need for me to validate what comes out.

Is there a chance that what is already in the datafile is corrupt ? If this is the case, then I have no choice but add the validatios even if I am doing a read, to prevent the program from falling over
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 3740

Hi Mxolisi,

Maybe there is just a misunderstanding

In my Data class I just validate the String[] against the schema information I have. So if your validator does the same, that's ok! But if you are validating the customer number too in your Validator and check if it is an 8 digit number, I don't think that's the correct approach. Because this would make your Data class not reusable for a similar data file with customers or hotels.

Kind regards,
Roel
Kevin Broderick
Ranch Hand

Joined: Jul 19, 2009
Posts: 39
Hello ranchers,

what I have done in validating so far bodgitt and Scraper project, I have validation methods implemented within the business class. So for the booking number, I just pass this number to the method bookContractor and within it calls private methods that checks that the number is numeric, is of no more that a size 8 and that there is a number entered. This was not a requirement but I though it to be ideal to ensure that the customer number was kept within constraints to the data and I also believe that the business class was responsible for overseeing it.

Cheers

Kevin
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2114

Howdy, Kevin!

I agree with you. You know, I myself didn't do this validation, but I don't see this validation as a problem (verifying if the provided number is 8-digit). What I did do is block the customer ID field in the GUI, so you can only provide numbers, and not any other characters.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Kevin Broderick
Ranch Hand

Joined: Jul 19, 2009
Posts: 39
Spot on Roberto
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 3740

I think server side validation should always occur, client validation is an extra, but not required. Your server could be used by another application and the gui might not so restrictive as your gui.

Kind regards,
Roel
Kevin Broderick
Ranch Hand

Joined: Jul 19, 2009
Posts: 39
Thats true Roel. I also think that the business class should do as much as it can with the data so as gui developers can concentrate with issues like gui layout and design and not worry about the issues surrounding the working with data such as validation.
bernard adaba
Greenhorn

Joined: May 15, 2009
Posts: 28
If anything at all, i think a validation on the server side or the controller is much preferrable to the GUI.
this is because the GUI may vary overtime from client to client and those validations may not be existent in them
at different client usages.

warmest regards
Bernard

SCJP 5, SCJD
 
 
subject: Are validations needed on the frontend GUI
 
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture