aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Business Layer, Factory and and Business Layer Search method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Business Layer, Factory and and Business Layer Search method" Watch "Business Layer, Factory and and Business Layer Search method" New topic
Author

Business Layer, Factory and and Business Layer Search method

Carlos Morillo
Ranch Hand

Joined: Jun 06, 2009
Posts: 221

Hello Everybody,


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.


Happy New Year!


Carlos.


SCSA, OCA, SCJP 5.0, SCJD, CCDH, CCAH http://www.linkedin.com/in/carlosamorillo
Daniel Breitner
Ranch Hand

Joined: Nov 13, 2008
Posts: 70
Do you publish your Business Leyer Interface by RMI or do you publish your DB Interface and create the BL on the Client?


Visit me at http://liferay-blogging.blogspot.com
Carlos Morillo
Ranch Hand

Joined: Jun 06, 2009
Posts: 221

Hi Daniel,


I still have not designed or implemented this, that's why I am posting these questions.

But I think if I want to make it a thin client I will have to publish
my Business Layer Object or Objects by RMI.


Thanks,


Carlos.
Daniel Breitner
Ranch Hand

Joined: Nov 13, 2008
Posts: 70
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.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5407
    
  13

Hi Daniel,

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

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Daniel Breitner
Ranch Hand

Joined: Nov 13, 2008
Posts: 70
... and your solution also reduces network traffic.
 
 
subject: Business Layer, Factory and and Business Layer Search method