CSCE 155

In-Class Forum 1:  Disaster Relief System

 

September 2, 2005

 

Introduction

 

Today, we talked about a problem.  In view of the Hurricane Katrina disaster, Red Cross wants you to build a Disaster Relief System that is able to track donations and deliver donations to victims.  You were required to work in groups of three to come up with a plan. 


The actual steps of the forum were:

 

  1. Come up with the most important 5 classes/objects needed to build the Disaster Relief System.  5 useful (and popular) classes were then announced.
  2. Pick one of the five classes and come up with 5 data members and 5 methods for that class of your choice.

 

Here are the results.

 

Step 1

 

The following table lists the good/appropriate classes, bad/inappropriate classes, and “okay” classes.  Bad/inappropriate classes are definitely “no-no”.  “okay” classes could be okay depending on your actual definition and the intended use.  Also, usually a good/appropriate class is a noun.

 

Good/Appropriate Classes

Bad/Inappropriate Classes

Okay

Red Cross

DisasterReliefSystem

Employee

Donation

Blood

Food

Clothes

Phone

Donor

Volunteer

Vehicle

Driver

Loader

Road

Gas

Medication

Money

Distributor

Delivery

Donation

Victim

Equipment

National Guard

Aircraft

Location

Feedback

Water

Health

Shelter

Recipient

 

These are more appropriate as methods of a class:

 

Track

Deliver

inputDonations

viewDonations

figureOutWhoNeedsDonations

addressDonationEnvelopes

printAddressLabels

AnalyzeNeeds

TrackElectronically

TrackSequentially

inputDonations

deliverDonations

SortDonations

trackDonations

formulateNeed

CentralLocation

InventorySystem

Air

Ground

Helicopter

Plane

Truck

 

 

These are more appropriate as data values/members of a class:

 

VictimName

VictimAddress

VolunteerHours

RequestType

DonationType

VictimLocation

DonationTruckRoute

ShippingType

NeedLocation

DonationNeed

 

 

 

 

Verbs or actions should not be classes; they are more likely methods for some class.  Not all nouns are appropriate as classes.  For example, if you look at “VictimName” and “VictimAddress”, these are not appropriate as classes.  Usually, it is more appropriate to do this:

 

class Victim  {

   private String name;

   private String address;

 

}

 

In the above, “name” and “address” are data members of the class “Victim”.  It is more logical.  Go through the list of terms filed under the “bad/inappropriate classes” and think of how better to represent them in your world of objects – if they are methods, which class should they belong to?  (for example, “inputDonations” probably should belong to the class “Donation”); if they are data members, which class should they belong to?  (for example, “VolunteerHours” should be represented as a “hours” data member for the class “Volunteer”)

 

At the end of Step 1, basically Red Cross picked the five (roughly) most popular and useful classes:

 

Donation

Victim

Donor

Volunteer

Delivery

 

Step 2

 

The following table lists for each of the selected class the data members and methods proposed by you.  Once again, there are good/appropriate choices, bad/inappropriate choices, and “okay” choices. 

 

Donation (8 teams chose this)

 

Data Values/Members

Methods

Good/Appropriate

type

size

volume

weight

amount

donor

origin (or source)

destination

location

recipient

money

lbsFood

pintBlood

sendDonation()

getDonatin()

getNumberOfDonation()

setNumberOfDonation()

getDonationAddress()

setDonationAddressToDeliver()

inputOrigin()

setDestination()

getDonor()

setDonor()

getType()

setType()

setOrigin()

setAmount()

getAmount()

getDestination()

sendDonation()

printSummary()

sendConfirmationOfReceipt()

sendDonation()

getDonorInfo()

recordTime()

getMoney()

getFood()

getBlood()

 

Bad/Inappropriate

food

money

water

medicalSupplies

clothing

donorName

donationOrigin

donationType

donationSize

donationTime

donationType()

donationAmount()

donationGiver()

donationPriority()

donationStatus()

getDonationType()

getDonationSource()

getDonationInfo()

 

Okay

member

need

sortDonation()

sortByAmount()

sortByType()

sortByLocation()

mapDestination()

giveBlood()

giveMoney()

giveFood()

 

In the above, I put “donationOrigin”, “donationType”, etc. as bad/inappropriate data members even though semantically these are appropriate.  Think about how to implement this “Donation” class:

 

class Donation {

   public String donationOrigin;  // we will use “public” just to illustrate

   public String donationType;

  

}

 

Does it make sense?  Now, let’s see why I think it does not make sense.  Let’s say you declare and create a “Donation” object:

 

Donation someDonation = new Donation();

someDonation.donationOrigin = “Nebraska”;

someDonation.donationType = “Corn”;

 

Do you see the “unnecessary” use “donation”?  The correct names should be:

 

class Donation {

   public String origin;  // we will use “public” just to illustrate

   public String type;

  

}

 

And now, you can use something like this:

 

Donation someDonation = new Donation();

someDonation.origin = “Nebraska”;

someDonation.type = “Corn”;

 

The above now reads more sensibly and logically too.

I also put “getDonationType()” in the bad/inappropriate category for the same reason.  A better name is “getType()”. 

 

In the following, I use the same strategy to divide the proposed methods and data values into the three categories.

 

Delivery (5 teams chose this)

 

Data Values/Members

Methods

Good/Appropriate

destination

origin (or start)

transportationType (or transportationMethod)

inventoryValue

amount

equipment

distance

location

numberOfTrucks

numberOfSupplies

cost

cargo

gas

shippingCost

transport()

confirmationOfDelivery()

confirmDelivery()

findOrigin()

loadGoods()

findDestination()

unloadGoods()

dropoff()

pickup()

fly()

drive()

inputLocation()

assignUnits()

inputModeOfTransportation()

loadSupplies()

loadCargo()

assignDriver()  (very nice!)

figureRoute()  (very nice!)

figureCost()  (very nice!)

packageDonation()

ship()

loadOnTruck()

Bad/Inappropriate

truck

driver

costOfDelivery

deliveryMethod

 

Okay

numberOfVictims

truck

driver

address

name

returnAddress

sorting()

packaging()

 

Victim (3 teams chose this)

 

Data Values/Members

Methods

Good/Appropriate

int age  (good!)

gender

String location (good!)

String name (good!)

String healthStatus (good!)

myNeed

float money (good!)

void setAge(int) (good!)

int getAget() (good!)

getGender()

setGender()

contact()

evacuate()

getName()

setName()

getLocation()

setLocation()

getHealthStatus()

setHealthStatus()

getMoney()

setMoney()

Bad/Inappropriate

 

sendProvisions()

sendMedicalAid()

giveShelter()

run()

walk()

beg()

stealMoney()

loot(String store)

liedown(String location)

Okay

 

changeInMoney(float amount_stolen)

 

Please pay attention to the “bad/inappropriate” methods.  The methods “run()”, “walk()”, “beg()”, etc., are methods that a victim might do.  Perfectly okay.  But when we come up with the methods, we must think of the purpose of the programming task.  The task is to build a Disaster Relief System … thus, it does not make good sense to have a scenario where a programmer would find “victim1.beg()” useful when designing and implementing the system.  However, if your application is to build a real-world simulation of how victims move in the disaster area, how victims behave, how victims interact with other victims, etc., then the above methods would be good and appropriate.  So, make sure you pay attention to the problem that you want to solve. 

 

Now, do you know why I also put “sendProvisions()”, “sendMedicalAid()”, and “giveShelter()” in this category?  These are methods or actions that one does to a victim; there are not methods that a victim normally does.  As a result, they are not appropriate. 

 

Volunteer (2 teams chose this)

 

Data Values/Members

Methods

Good/Appropriate

String location (good!)

String name (good!)

String skill (very good!)

String affiliation (very good!)

int volunteeringLength (very good!)

name

number

location

age

jobSkill

transportTo()

task()

returnHome()

Bad/Inappropriate

 

run()

loot()

swim()

jump()

skip()

Okay

 

 

 

I put “run()” and the other methods in “bad/inappropriate” based on the same reason used in the previous classes.