Assessment Details

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.

Step 1 Rename the base code

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.

Step 2 Begin a report document

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.

Step 3 Create a class diagram of the initial code.

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.

Step 4 Start refactoring and developing your unit tests

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.

Step 5 When you have finished refactoring

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.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.