• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serializing String[] vs HotelRoom over a network

 
Mxolisi Veco
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day all.

I find Serializing HotelRoom instances to the server not easy to work with since I am forced to make sure that the end-user captures a Date, price, owner and size of the room when searching for records.
I want to allow the end-user to search for all the rooms in the database by allowing him/her to leave out certain fields such as the owner, price, date etc. I am not able to do this when I serialize HotelRoom since HotelRoom class has member variable int price, double rate, etc. I force a user to capture these details as a result.

On the other hand, if I serialize String[] I can ignore these validations and allow a user to retrieve all the records in the database.

Is it a must that a hotelRoom instance is serialized over the network from the client ?
I am thinking I must send String[] to the server instead of HotelRoom.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mxolisi,

I don't see the actual problem: in your gui you have a name and location to search on (the required criteria according to the instructions). When the user hits search you compose a HotelRoom with the criteria provided by the user (the other data members will be empty or have default values). Your business service method has only interest in the name and location properties (so will ignore all other ones).

As an alternative you could create a seperate transfer object which will be used only for searching. The main advantage is that you can add criteria that are not part of the data members of a hotel, like a start rate and end rate (when a customer only wants a room between 100 and 150 dollars in paris). I prefer this approach (and that's why I used this one myself )

And as a small remark: if you have a double for price/rate, that's maybe too much (you had to deal with the dollar sign for example). My HotelRoom object just contains 2 Integers (id and size of a room) and 1 Boolean (smoking), all others are Strings.

Hope it helps!
Kind regards,
Roel
 
Mxolisi Veco
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Roel.

I think It is best that I change my HotelRoom to contain Strings only instead of int/double/Date for owner and price and date. This is going to make life easier for me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic