I hope you all had a nice and Happy Merry Christmas.
I am almost finished with my Data class, I am able to persist and read a Database file I create
and I am able to run up to 1000 iterations the DataClassTest of Roberto Perillo without any deadlocks.
Now, after reading some of the multiple threads in this wonderful forum, I need to continue my assignment
but I am unclear about a few things.
I want to write a Business Layer where I will have 2 methods:
- Book a Room.
- Search for all records or for records where the name and/or location exactly matches values specified by the user.
These 2 methods will be the only ones exposed to the GUI client.
Writing this Business Layer I want to make my GUI client "thin".
I read Andrew Monkhouse's book and I have seen he uses a Factory for the DVDDatabase object.
This is my interface for URLyBird 1.1.3:
The questions I have and I am unclear about how to proceed are:
1. Do I need to create a Factory for my Business Layer object?
I suspect yes, but I am unsure if the signature of my lock() and unlock() methods offer any advantages as far as identifying
the clients which is why sometimes a Factory is needed.
2. Do I need to create a Factory for my Data Object? I suspect the answer is no.
3. I have seen some folks here describing the Business Layer with an interface and this should be implemented
by a Local Services Object and by a Remote Object Services Object.
Not quite clear about why.
Would this accomplish the same effect as Andrew Monkhouse's Local and Remote DvdConnector in Denny's DVDs?
4. In The Business Layer search method I have seen some folks returning a List<Room> and others Map<Integer, Room>.
I guess this is relevant to how each person solves this? Or are there any advantages to returning one or the other?
I am aware this will be used by the JTable's TableModel in the Swing GUI.
5. I have seen some people talking about a SearchCriteria object that could possibly have 2 String attributes:
name and location.
Is this a valid approach? I am unclear about this also.
I was thinking when the user doesn't specify name and/or location or if
the user specifies name and/or location perhaps the command pattern could help perhaps with an Enum command
NOP, AND, OR but I have seen others talking about the strategy pattern.
Thanks in advance for your help.
Just want to continue making progress and trying to finish my assignment ASAP.
Funny thing: Today I also thought about that.
One reason why I didn't wanted to have a thin client was that changes on the client then would also mean changes on the server.
If the business functionality would reside on the client the server could stay as it is.
On the other hand: if you have to change business functionality when it resides at the client (for example: add a test to check if the record/room a CSR has selected is still the same record/room from database, to verify that the price for a night is not changed or maybe the night it's available has changed) you have to make this change and replace all your clients with this new version. When this business logic is at the server (thin client) then you just need to expose a new version of your server (if you don't modify the signature of your business methods of course) instead of replacing all the clients.
So it's just one of the decisions you have to make and explain it in choices.txt