I am working on the URLyBird assignment, and I make the criteria in a way I think it can be better, but I dont know how to do that improvment.
(Rinke makes me think about this after I read his topic about using
string array or an VO...)
I have created a business layer, and an exclusive package for that. This layer is an adapter (adapter
pattern) between the DBAccess interface to my new clean and easy to use business interface. The business interface is the one I am exposing via RMI to the clients.
And I have the following method in the business interface:
public ArrayList<Room> searchRoomsByCriteria(SearchCriteria criteria) throws IllegalArgumentException, BusinessFailureException; Look at the parameter: I created an SearchCriteria (serializable class), just with the hotel name string and city location string (2 strings).
When the client wants to serach for the hotel name called "Palace", it need to create a SearchCriteria object, set the hotelName instance variable to "Palace", and call the method passing the object as the parameter.
Inside the method, I am creating an array of string with the fields of SearchCriteria (criteriaFields), and comparing with the just readed values from the database for a record (fields), as follow:
But my assignment talks about to create a flexible search mechanism. Is my implementation that flexible? I am not sure, I heard people talking about to use the strategy pattern in the criteria... I would appreciate some oppinions.
Thanks a lot,