Appointment
date:Date
start:Time
end:Time
desc:String
type:AppointmentType
Scenario
Calendar
add(Appointment):void
*
Oops - Encapsulate Type Code to State
appointments
type
!
AppointmentType
Regular
Todo
AllDay
Encapsulating the type codes in a separate class avoids this probem.
An Appointment can change its type dynamically by reassigning its AppointmentType instance.
We can compare this design to the original to see the improvement [flip slides].