80 likes | 92 Views
This specification outlines a static model with behavior for a scheduler that manages courses, sessions, and instructors. It includes specifications for duration, start and end dates, confirmed status, client information, and more. It also defines invariants to ensure consistency in the system.
E N D
Static model with behavior Scheduler courses sessions instructors * * instructor 0..1 Course Session Instructor sessions * duration: Duration start: Date end: Date confirmed: Boolean; Boolean overlaps ( Session); client: Client * sessions rating: Grade free(Date,Date) course Static model 1 * * qualifiedFor qualifiedInstructors Invariants: inv Instructor::qualifiedFor->includesAll(sessions.course) sessions->forAll(s1,s2|s1<>s2 ==> not s1.overlaps(s2)) inv Session:: confirmed ==> instructor <> null and end = start+course.duration
Redundancy in specifications • Which parts of the following specification are redundant?
Minimal specification Action Scheduler::change_dates (Session s, Date d) pre: s.start > now and (1) s.course<>nil and (2) s.course.duration : Duration (3) post: s.start = d (4) s.end = d + course.duration (5)
Minimal specification Action Scheduler::change_dates (Session s, Date d) pre: s.start > now and (1) /pre s.course<>nil and (2) s.course.duration: Duration (3) post: s.start = d (4) /post s.end = d + course.duration (5)
Question 2 • Implement the following specification
Static model with behavior Scheduler courses sessions instructors * * instructor 0..1 Course Session Instructor sessions * duration: Duration start: Date end: Date confirmed: Boolean; Boolean overlaps ( Session); client: Client * sessions rating: Grade free(Date,Date) course Static model 1 * * qualifiedFor qualifiedInstructors Invariants: inv Instructor::qualifiedFor->includesAll(sessions.course) sessions->forAll(s1,s2|s1<>s2 ==> not s1.overlaps(s2)) inv Session:: confirmed ==> instructor <> null and end = start+course.duration
Specification Action Scheduler::schedule_course(who: Client, c: Course, d: Date) pre: c.qualifiedInstructors->includes (i|i.free(d,d+c.duration)) post: s:Session.new[confirmed & client= who & course=c & start=d]