Java Cinema Booking Client and Server

Another University project that I want to talk about is a client/server cinema booking system written in Java. I worked with my good friend Nathan on this as it could be completed in pairs. We used GitHub (obviously) to host the project and the repo can be found under Task2.
We achieved a mark of 90% for this as we implemented all of the requirements to a good standard. We also had a report to produce, explaining design choices, etc. It’s not interesting, but the report’s here if you want it.
The main points that I’d like to discuss about this project are:

  • Implementing Multithreading

    Multithreading is the ability to run code in parallel within one process. Java makes this very easy by providing a Thread and Runnable classes to allow developers to extend or implement. The main problem that we faced when dealing with multithreading was multiple access to data. We had a central object on the server which contained all data, two threads (read user connections) should not be able to read from or write to this object at the same time. Access to this critical region was controlled by synchronising access to objects with synchronised methods and the synchronised keyword.

  • Building a protocol

    As this project was quite large (Nathan and I had not dealt with a project of this scale before) we needed to ensure that there was a formalised way of communicating between clients and servers. This helps to ensure that the server and clients can communicate easily and also makes it easy to notice an error. We built two classes to model the client/server communication in this project; a Request class, and a Response class. We chose these names as we felt that they fitted the nature of the connection. A client makes a ‘Request’ to the server (to log in, to make a reservation, etc.) and the server passes back a ‘Response’ with details of what happened (the result of a query, success message, error message, etc.)

  • Graphical User Interfaces

    Initially we had veto’d this aspect of the project as we were daunted by the scale of the project and didn’t think we should have enough time to learn and implement an AWT/Swing Java graphical interface. In the early stages of the project, while I was working on the basics of the server, there wasn’t anything Nathan could have been doing so he decided to look into Swing and took well to it quickly so we changed out mind about implementing a GUI. Nathan implemented most of the interfaces that are in the project, the rest were from my reuse of his code.

I loved this project and learnt a lot about software development, Java, and the client server model.