• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Are validations needed on the frontend GUI

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Mxolisi Veco
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Roel.

I will add the valaditions on my Data class.
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Kevin Broderick
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spot on Roberto
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
I promise I will be the best, most loyal friend ever! All for this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic