Forums Register Login

NX: Identify pattterns used in my design

+Pie Number of slices to send: Send
Hi,
I took two weeks to finish the design and implementation. (Exclude night time). I chose Socket implementation over RMI. Here is the design.
Classes
  • DataFile - read, write & validate random access File.
  • Data implements DBAccess - include HashMap for locking.
  • BookingManager - Business methods, need an instance of DBAccess through its constructor.
  • DataProxy implements DBAccess - provide networking to server
  • MainServer - ServerSocket multithreaded server, need DBAccess, in this case a instance of Data.
  • ClientService - thread created by MainServer for each client connection, uses Data which in turn use DataFile.


  • Standalone
    MainClient <-> BookManager <-> Data <-> DataFile
    Network
    MainClient <-> BookManager <-> DataProxy <==n/w==> ClientService <--> Data <-> DataFile
    Can anyone help me to identify one or two design patterns used. I am not very good in patterns.
    Many thanks. Sorry for incomplete earlier thread.
    +Pie Number of slices to send: Send
    Hi Frankie,
    I don't recall you needing to identify your patterns for the assignment, but here's a couple:
  • Proxy: Having one class stand in for another class.
  • Adapter (wrapper): modifies the interface you don't want (DataInterface) into an interface you do want (BookingManager)


  • Regards, Andrew
    +Pie Number of slices to send: Send
    Hi,

    I don't recall you needing to identify your patterns for the assignment


    I thought this was one of the main points of the choices.txt?
    Chris
    +Pie Number of slices to send: Send
    You might want to rethink ServerSocket. It is platform dependent.
    +Pie Number of slices to send: Send
    Hi Jim,
    ServerSocket is platform dependent ?! What do you mean ? Could you be more precise ?
    Best,
    Phil.
    +Pie Number of slices to send: Send
    Hi Jim,
    I have implementations using ServerSocket that runs on Win, Linux, Mac and Solaris. I don't understand what you mean? I am referring to java.net.ServerSocket.
    Thank you Andrew for pointing out the patterns.
    Best Regards,
    Frankie
    New Question on patterns, I got the Trottier's book which I think it is not very good. The author highlighted he used Decorator patterns to handle the local and networking parts. I could not understand what he is talking about. Maybe I am slow in understanding. Could you post reply on how Decorator is used in this?
    Thank you and best regards.
    +Pie Number of slices to send: Send
    Hi Chris,

    Originally posted by AndrewMonkhouse:
    I don't recall you needing to identify your patterns for the assignment
    Originally posted by Chris Harris:
    I thought this was one of the main points of the choices.txt?


    You can certainly add these to your choices.txt file (and I did in my submission), and it may help your examiner understand your submission, but it is not required as far as I know.
    Regards, Andrew
    +Pie Number of slices to send: Send
    Hi Frankie,
    The decorator pattern is used to transparently add functionality to a class. It is not meant to be a wrapper, and it is not meant to extend the class.
    To give you an example:

    I have tried to keep the example to Alain's concept of a seat booking system
    In that example, you can see that I can use the basic class or one of the decorator classes interchangeably. However if I use a decorator class I get extra functionality (an extra charge is added). I could just as easily have overridden the basic methods as well if extra functionality was needed in the method itself.
    Alain has come close to this concept by specifying the DatabaseInterface interface, and having both Database and DatabaseRMIImpl implement it. This means that the same code can be used on the client side regardless of which type of connection you have:

    However this is not a decorator pattern.
    You could see in my example that using the decorator pattern meant that if an extra method had to be added, I could add it to the abstract Decorator class, and all the decorations would inherit it automatically. You cannot do this with Alain's classes - you would have to add the new function to the DatabaseInterface, the Database class, and the DatabaseRMIImpl class.
    You can see in my example that you can apply multiple decorations to the base class, and that it is done transparently. You cannot do this with Alain's classes. You cannot (to give a wierd example) wrap a serialized socket call inside an RMI call or the other way around.
    Alain is using the Proxy pattern to have one class stand in for another class.
    Regards, Andrew
    +Pie Number of slices to send: Send
    Hi Frankie,

    Originally posted by Frankie Cha:
    I got the Trottier's book which I think it is not very good.


    Perhaps you could add your comments on what you liked / disliked about the book in our book review comments page. The one for this book is here. That way others can see what you thought which could help them decide whether to get the book or not.
    Regards, Andrew
    +Pie Number of slices to send: Send
    I blanked out. I meant socketchannels. I can't find a stupid graemlin.
    +Pie Number of slices to send: Send
    Thank you Andrew for the detailed explanation, I promise to post the likes and dislikes about Trottier's book when I am through with the book and the SCJD exam.
    Best Regards,
    Frankie
    +Pie Number of slices to send: Send
    i think u guys r u using way to complex design patterns which simpler patterns can achieve the same result, it is always to keep things as simple as possible.
    I yam what I yam and that's all that I yam - the great philosopher Popeye. Tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 1042 times.
    Similar Threads
    Can Someone Explain To Me What This Means?
    NX: Opening and closing the file
    NX: suncertify.properties
    NX: Maintain Look Cookie in DBAdapter
    NX: Database vs Data / MetaData
    Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 18, 2024 20:04:36.