aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: the third layer. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: the third layer." Watch "NX: the third layer." New topic
Author

NX: the third layer.

Bigwood Liu
Ranch Hand

Joined: Feb 26, 2003
Posts: 240
Hi,
I saw many issues here that business layer class only has three methods: book, search, getMateInfo. how do you close the database in local mode?
I think it is convenient to add method close. Need your comment.
Best,
Damu
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
Hi Damu,
PS (first time that I start a post with a PS) : I just noticed when posting this that you deleted and recreated the thread I was replying to. So don't be surprised if I quote you from the previous one : I am too lazy to change them ...
I saw many issues here that business layer class only has three methods: book, search, getMateInfo.

Methods book() and search() for sure, but some getMetaInfo() not IMO, at least with that wide scope (see below).
How do you get the name & location values to fill the JComboBox(Contractor)? And how do you close the database in local mode?
I think it is convenient to add three more methods: readRecord, getRecordsCount, and close. Need your comment.

It seems obvious, but the purpose of a "business" tier is to give access to data and behaviours which fall in the immediate upper tier's business.
If your business tier starts with giving access to some part of the lower level datastore, your design is not 3-tier but 2.5-tier.
And the problem comes with the fact that you loose the main benefit of the 3 separate layers you had in mind : to get your upper layer 100% independant of the way - and where - data is stored. Think of redesigning your business tier interface till you can conclude :
OK, whatever will happen tomorrow at the data level :
  • we move from our single flat-file-system to a relational database
  • or we replace our binary flat-file by an XML file
  • or we now get data from a web service
  • or ... whatever a new way of storing and getting data will be invented tomorrow


  • (...), I'll don't need to change the business tier public interface (of course as far as the business needs don't change themselves).
    book() and search() methods represent business behaviours, or actions.
    What you'd like to get besides is some business information (I used the word information instead of data on purpose, to make clear that it has nothing to do with the DB-level data) :
    a list of the possible search criteria with, for each of them possibly a description, and for sure a list of all possible distinct values. All this could be carried in one object as the returned value of some getQueryInformation() business method.
    It's just an example, and you may have additional such "abstract" needs, but the main idea is there.
    Best,
    Phil.
    [ October 26, 2003: Message edited by: Philippe Maquet ]
    Bigwood Liu
    Ranch Hand

    Joined: Feb 26, 2003
    Posts: 240
    Hey Phil, I changed the post because I think the readRecord, getRecordCount is , as you said , 2.5 layer. So I deleted it. Thank you very much, you are a really cool man! I read your answer with this:
    Bigwood Liu
    Ranch Hand

    Joined: Feb 26, 2003
    Posts: 240
    Hi Phil,
    do you close the database from GUI? Then the third layer should have closeDatabase().
    I alse have getDatabaseInfo() as a business method.
    best
    damu
    Philippe Maquet
    Bartender

    Joined: Jun 02, 2003
    Posts: 1872
    Hi Damu,
    you are a really cool man!

    Hope I am ! It's quite tough to reply to questions you're not supposed to have posted !
    do you close the database from GUI? Then the third layer should have closeDatabase().

    No I don't. It's difficult to reply to that question, Damu, because I don't know exactly what you mean - in your design - by "closing the database".
    In my design, there is no logical relation between client connections to the server and the "open" state of the database. When the server starts, the database is opened once. After that first step, my server is listening for possible clients and keeps the database "open". Clients may then connect, disconnect, reconnect, do whatever they want, the database simply keeps its "open" state ... till the server shut down. (I simplify a bit on purpose).
    I alse have getDatabaseInfo() as a business method

    It's perfect IMO, as far as getDatabaseInfo() returns abstract information and not low-level data (see previous post).
    Best,
    Phil.
    [ October 27, 2003: Message edited by: Philippe Maquet ]
    Bigwood Liu
    Ranch Hand

    Joined: Feb 26, 2003
    Posts: 240
    Hi Phil., thank you for reply.
    Hope I am ! It's quite tough to reply to questions you're not supposed to have posted !
    Yes, I agree with you.
    Damu, because I don't know exactly what you mean - in your design - by "closing the database".
    I mean in alone mode, we will open a local database, but who is supposed to close it?
    Best,
    Damu
    Philippe Maquet
    Bartender

    Joined: Jun 02, 2003
    Posts: 1872
    I mean in alone mode, we will open a local database, but who is supposed to close it?

    Your lonely client.
    [ October 28, 2003: Message edited by: Philippe Maquet ]
    Bigwood Liu
    Ranch Hand

    Joined: Feb 26, 2003
    Posts: 240
    Laughing... You are very humourous.
    You lonely client

    So the lonely client should have a close() method to close the local database.
    Best,
    Damu
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: NX: the third layer.
     
    Similar Threads
    to make a layer appear upon press a link
    How to handle a JDBC DAO 's Exception?
    Synchronization Problem whil accessing JDBC Code
    project architecture
    unlock a deleted record, how to?