DavidWood2001-zz / SOFT152-Assignment

This is a repo that contains all of the files for the SOFT152 assignment, also known as the AirBnB Assignment.
0 stars 0 forks source link

Make sure that when an error is thrown no object is created #14

Closed DavidWood2001-zz closed 4 years ago

DavidWood2001-zz commented 4 years ago

At the moment when an error is thrown the object is just created with whatever attribute had that error being set to the data types equivalent of null (e.g. int 0 or string ""). This is not acceptable as it means that objects can be created even if those objects are completely empty and meaningless in nature. For example if a user enters no name, hostID, hostName or latitude all will be defaulted to null making it harder for the search function in the future to return useful results. To avoid this the user needs to be directed to correct their input before the object is created.

DavidWood2001-zz commented 4 years ago

One way of doing this is to add data validation at the front end but this is messy and creates duplicate and redundant code in the back-end.

DavidWood2001-zz commented 4 years ago

A more 'streamlined' approach would be to call the data validation from within the Property class onto the input as the validation is already created. This can be done by parsing the input values into the 'check' methods and then if none return a null then the object is created.

DavidWood2001-zz commented 4 years ago

All of the important data validation (constraints of the data) are completed before creating an instance and only if none of the data is incorrect then it will create an instance of property.cs and add it into the search table as a valid item.