Case StudyHomepage « Case Study

In this part of the site we do a non-trivial case study that reinforces what we have learnt in the other sections of the site. The case study will incorporate a GUI and several architectural patterns, such as MVC that was introduced in the  Swing  section of the  Learn Java6  part of the site. Where a new pattern or concept occurs within the case study that isn't covered elsewhere on the site it will be discussed in situ, otherwise we will just link to the relevant lessons at the end of each case study lesson.


Scenario & Setup

In this section of the case study we look at a project proposal and set up our environment. We start by looking at information gathered from the stake holder who we shall call 'Stocking Goods Limited' and how this can be translated into a multi tiered user application fit for purpose. With the basic requirements of the project proposal analysed we can build the file structure for our source and class files. We finish this section by writing code to create a Manufacturer test file to be used with the Case Study.


Model Part 1

In this section of the case study we look at the model code for our project and code as much of the model as we can from the information provided within the Project Proposal. The stakeholder Stocking Goods Limited have supplied us with a Stock interface that must be implemented and from this we can also derive some exception classes. In our first lesson of the section we code up the Stock interface and exceptions for our model code and compile them. The stakeholder has also requested that we create a class representing the record information within the Manufacturer file called unsurprisingly Manufacturer as they see a lot of future reuse of this file and it will also be helpful when implementing the Stock interface. The final thing we can do with the model at present is implement the Stock interface and create some method stubs we will come back to when we revisit the model code in the Model Part 2 section.


View Part 1

In our first lesson of the section we spend some time thinking about the overall design of the GUI. This includes the common panel we are going to display to the user on startup for the entry of the Manufacturer file location/port, and how we are going to display the Manufacturer data to users whilst allowing options to search, stock and unstock. In our first lesson of the section we draw up some rough sketches for our panels, make some design decisions with regards to user interaction with the panels and name some classes needed to implement our design choices. We will begin coding the view part of the MVC pattern, starting with the classes that are independent of other classes within the Manufacturer application. We finish the section by compiling the code for the Manufacturer application startup and also the saved run mode / run mode options.


Controller Part 1

In this section of the case study we do the first part of our controller code by creating an exception class for our services and the Services and RemoteServices interfaces.


Model Part 2

In this section of the case study we finish off the model code for the case study. To do this we will have to add some imports to the StockImpl class and complete the method stubs we left for this section of the case study. We will start by completing the search() method and then finish the model code by completing the stocking() and unstocking() method.


Controller Part 2

In this section of the case study we complete our controller code by implementing the RemoteServices and Services interfaces. The RemoteServices interface will provide remote access to and interaction with the Manufacturer file from a remote client, whilst the Services interface will provide local access to and interaction with the Manufacturer file from a local client.


View Part 2

In our final section on coding the case study we complete the view code elements. We start the section by coding the RunModeDialog class which creates a dialog box to accept and validate run mode options for the Manufacturer application. We then implement the code for when a user has entered the manufacturer application with a run mode of "server". We finish the section and complete the coding for the Manufacturer application by coding the ManufacturerWindow class and uncommenting the instantiations of the ManufacturerServerStartupWindow and ManufacturerWindow objects within the ManufacturerApplicationStartup class.


Testing & Wrap Up

In the final section of the Case Study we do some testing and wrap up the loose ends. We start by writing a program to test various methods of the StockImpl class which will also test the Manufacturer class in the process. We will write out methods called to a log file and view the logged results, thus also testing that our logging is working as intended. After this we write a test program to validate our locking is functioning correctly. For the view code we do some visual checks to ensure the GUI is working correctly. This will include starting up the Manufacturer application in non-networked client, server and networked client modes as well as checking that the visual presentation of the manufacturer data file is displayed correctly using our custom table model. In our final test for the case study we do some visual checks to ensure the controller code is working and end-to-end testing to show that the disparate parts of our system function together correctly. We have been using javadoc comments throughout the code we have written and we finsih the section by creating the javadoc documentation for the packages we have coded. We then wrap all our files up neatly in a jar file so we can easily distribute them and to also reiterate usage of the jar command.


go to home page Homepage go to home page Top