You are given a copy of an existing JAVA application which is responsible for taking bookings for a hospital system, this application is badly in need of refactoring and even a casual viewing of the source code reveals many examples of the code smells talked about in Fowlers book. The base application consists of four classes MainClass, Doctor, Patient and Hospital. A patient can be a private or public patient and is handled differently in either case. Patients are assigned to Doctors according to availability and preference.
1. Create a new project in Eclipse and Assignment 1 yourid (your id equals your student number)
2. Import the four files MainClass.java, Doctor.java, Patient. java and Hospital.java - into the project you have just created.
3. Run the program. You will find that it has created a file called MyOutput.txt in the working directory. If you wish to use a different folder you will need to update the output file in MainClass.java. The output of the program will be displayed on the console and written on the output file.
Open up a new document in Word (or equivalent), start jotting down any code smells you identify in the code in point form (you might want to cut and paste the code into word to illustrate the problems). This will form a report that you will need to include in your assignment submission. There are two important bad smells you must address the long method in the Hospital class and the long class smell of the Patient class. However, there are others you should look at as well.
Create a class diagram of the given code in Enterprise Architecture (EA). This should be included in your final submission. The diagram should be in your report as well.
Ensure that starting code files, initial output file and EA file is backed up, and once this is done jump back into Eclipse and get to work refactoring. Each time you complete a refactoring, run the program and then test if the program output is the same as the output before refactoring. You can rename the output file so that you can check them. You can write a simple JAVA program to check if two output files are the same or not so that you do not have to manually inspect them. If the two outputs files (before and after refactoring) are different, it is because the output has been changed. Refactoring should not change the output so you will need to look at the code you have already written before you move on.
Create a second class diagram in Enterprise Architecture of the final refactored code. This should be included in your final submission. The diagram should be in your report as well.