Forums Register Login
NX: Identify pattterns used in my design
I took two weeks to finish the design and implementation. (Exclude night time). I chose Socket implementation over RMI. Here is the design.
  • 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
    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.
    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

    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?
    You might want to rethink ServerSocket. It is platform dependent.
    Hi Jim,
    ServerSocket is platform dependent ?! What do you mean ? Could you be more precise ?
    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,
    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.
    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
    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
    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
    I blanked out. I meant socketchannels. I can't find a stupid graemlin.
    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,
    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.

    This thread has been viewed 880 times.

    All times above are in ranch (not your local) time.
    The current ranch time is
    Oct 17, 2018 16:50:12.