CS517-FinalExam2013

advertisement
CS517 – Major Assignment 1
Submit via ramCT by Sunday, March 10, 2013, 11:55pm
PLEASE READ THE FOLLOWING
This is a take-home exam. You can consult the course notes and the textbook,
but under no circumstance are you to discuss the questions and possible
answers with anyone else (except the lecturer), and you are not allowed to solicit
answers to the questions from others (including via the internet). All questions
about the exam must be communicated directly to the lecturer(s). Plagiarism
(copying from another student or from another source) is not allowed and will be
dealt with severely. Doing any of the above is considered cheating. If evidence is
found of cheating you will get a 0 for the final exam, and you will be dropped 1
letter grade. Furthermore, we are required to report you to the appropriate
authorities at the University and the outcome could be an entry on your transcript
indicating a cheating offense has occurred. Again, you are allowed to contact the
lecturer if you have any clarification questions about the exam (… ofcourse we
cannot give you the answers to the exam questions but we can help clarify the
questions and correct typos etc.).
You must answer questions 1, 2
PLEASE TYPE YOUR NAME BELOW (if you do not include your name on
the major assignment you will get a 0!)
NAME ________Brock Wilcox_______________________________
1. (55 pts) Develop a requirements class model for the DVD library system problem
given below. The model must consist of (1) a requirements class model in which
invariants are expressed in the OCL, and (2) use case description for three system
operations of the DVD library system. Your use case descriptions must have the
following sections: Use case name, precondition (must be true before the
operation can be started), main and exceptional behaviors. You can have
additional sections if it helps the readability of your use cases. State any
assumption you make to fill in any missing information (your assumptions
must not contradict any explicitly stated requirement).
The DVD Library Problem
The system is required to keep track of DVDs rented out to students and
professors. DVDs are classified as scientific and non-scientific. The scientific
videos are further classified as Computer Science, Biology, Physics, and
Chemistry DVDs. Only students that belong to a Research Group can borrow
scientific DVDs from this library. Such students are referred to as research
students. A Research Group consists of 1 or more professors and 0 or more
students. A research student can check out scientific DVDs only in the department
they are registered in; for example, a research student registered in the Biology
Department can only check out Biology DVDs. A research student is registered in
exactly 1 department. Professors can check out any DVDs. Students can check out
any non-scientific DVDs. For each DVD, the system keeps track of the last
person to borrow the DVD (if the DVD is currently checked out, the borrower is
the last person to borrow the DVD). The system should allow a user to search for
DVDs by title and director. Please note that there may be more than 1 copy of a
DVD.
Assumptions:
 ScientificDVDs are owned by a single department
 Departments are limited to Computer Science, Biology, Physics, and Chemistry,
so we don't have to mention those in the diagram or OCL.
Solutions:
 DVDs are classified as scientific and non-scientific.
◦ This is done via inheritance of DVD to ScientificDVD and NonScientificDVD
 The scientific videos are further classified as Computer Science, Biology,
Physics, and Chemistry DVDs.
◦ This is done by linking ScientificDVD with a Department
 Only students that belong to a Research Group can borrow scientific DVDs from
this library.
◦ Done through the StudentScientificDVDDept invariant.
 A Research Group consists of 1 or more professors and 0 or more students.
◦ This is done in the UML via the StudentBelongsToGroup and
ProfessorBelongsToGroup associations
 A research student can check out scientific DVDs only in the department they are
registered in; for example, a research student registered in the Biology
Department can only check out Biology DVDs.
◦ This is done through the StudentScienceResearch invariant
 A research student is registered in exactly 1 department.
◦ This is done through the ResearchStudentInDept invariant
 Professors can check out any DVDs.
◦ This is implicit, since the restrictions on DVDs are only put on Students
 Students can check out any non-scientific DVDs.
◦ This is implicit, since only scientific DVDs are restricted
 For each DVD, the system keeps track of the last person to borrow the DVD
 If the DVD is currently checked out, the borrower is the last person to borrow the
DVD
◦ This is done through the CurrentIsLast invariant on Loans
 The system should allow a user to search for DVDs by title and director. Please
note that there may be more than 1 copy of a DVD.
◦ Added as DVDLibrary.search
◦ To deal with more than one copy, each dvd has an ID
Here is the 'use' file, which contains all of these relationships and constraints in detail.
model DVDLibrary
-- Classes
abstract class DVD
attributes
dvdID: Integer
title: String
director: String
end
class ScientificDVD < DVD
end
class NonScientificDVD < DVD
end
class DVDLibrary
operations
search(title: String, director: String): Set(DVD) =
dvds->select( d | d.title = title and d.director = director
)->asSet
end
abstract class Patron
end
class Student < Patron
end
class Professor < Patron
end
class Department
end
class ResearchGroup
end
class Loan
attributes
active: Boolean
end
-- associations
association ProfessorBelongsToGroup between
Professor[1..*] role professors
ResearchGroup[*] role researchGroups
end
association StudentBelongsToGroup between
Student[*] role students
ResearchGroup[*] role researchGroups
end
association StudentInDepepartment between
Student[*] role students
Department[1] role department
end
association PatronLoan between
Patron[1] role patron
Loan[*] role loans
end
association DVDLoan between
DVD[1] role dvd
Loan[*] role loans
end
association ScientificDVDDepartmentType between
Department[1] role department
ScientificDVD[*] role dvds
end
association LastBorrower between
DVD[*] role lastBorrowedDVDs
Patron[0..1] role lastBorrowedBy
end
aggregation DVDInLibrary between
DVD[*] role dvds
DVDLibrary[1] role library
end
constraints
context Loan
inv StudentScientificDVDDept:
let student_patron = patron.oclAsType(Student) in
let scientific_dvd = dvd.oclAsType(ScientificDVD) in
patron.oclIsKindOf(Student) and
dvd.oclIsKindOf(ScientificDVD)
implies
student_patron.department = scientific_dvd.department
inv StudentScienceResearch:
patron.oclIsKindOf(Student) and
dvd.oclIsKindOf(ScientificDVD)
implies
patron.oclAsType(Student).researchGroups->size() > 0
inv CurrentIsLast:
active implies patron = dvd.lastBorrowedBy
context Student
inv ResearchStudentInDept:
researchGroups->size() > 0
implies department <> Undefined
2.
(45 pts) The following is a partial Requirements Class Model for a scientific
manuscript submission and review system (MSRS) for a journal. Authors submit
papers (called submissions) to the system. A submitted paper is assigned to an
editor who is responsible for finding at least three scientists (reviewers) to review
the paper. Each reviewer prepares and submits a review for the paper. In the class
model, an EditorAssignment object represents an assignment of a submission to
an editor and tracks the reviewer assignments for the paper. A
ReviewerAssignment object tracks the reviewer an editor assigns to a paper.
CalDate is a date data type with the following operations:
- d1.isAfter(d2) returns true if d1 is a date after d2, and false otherwise.
- d1.isBefore(d2) returns true if d1 is a date before d2, and false otherwise. (Note
from the lecturer: someone is going to point out that one of these two operations
is unnecessary – you can ignore one of them if you feel strongly about it)
- d1.equal(d2) returns true if d1 is the same date as d2 and false otherwise
- d1.duration(d2) returns the number of days in the period d1 and d2 (including d1
and d2)
a. (30 pts) State the following invariants using the Object Constraint
Language (OCL).
i. For each submission (an instance of Submission), the submission
date (submitDay) must be before the review completion date
(reviewCompleted). (3 pts)
context Submission
inv SubmitBeforeReview:
reviewCompleted <> Undefined implies
submitDay.isBefore(reviewCompleted)
ii. The date that a reviewer completes an assignment
(completionDate) must occur after the date the paper is assigned to
the reviewer (revassignmentDate). (3 pts)
context ReviewerAssignment
inv CompletionAfterRevassignment:
completionDate <> Undefined implies
completionDate.isAfter(revassignmentDate)
iii. The date a reviewer is assigned to a paper (revassignmentDate)
must occur after or on the same date an editor is assigned to the
paper (edassignmentDate). (3 pts)
context ReviewerAssignment
inv ReviewerNotbeforeEditorAssignment:
let edAssign = assigningEd.edassignmentDate in
revassignmentDate.isAfter(edAssign)
or revassignmentDate.equal(edAssign)
iv. A completed reviewer assignment must have a review associated
with it. (3 pts)
context ReviewerAssignment
inv ReviewerCompleteReview:
completionDate <> Undefined
implies review <> Undefined
v. The paper assigned to a reviewer via a ReviewerAssignment object
must be the same paper associated with the EditorAssignment
object that is linked to ReviewerAssignment object. (3 pts)
context ReviewerAssignment
inv SameReviewAndEdit:
paper = assigningEd.assignedPaper
vi. A reviewer cannot be assigned more than once to the same paper.
(5 pts)
context Submission
inv NoRepeatReviewers:
assignedTo->isUnique(reviewer)
vii. If the status of a submission is UnderReview then at least one
reviewer has been assigned to the paper and less than three reviews
have been submitted. (5 pts)
context Submission
inv EnoughUnderReviews:
status = UnderReview implies (
assignedTo->size() >= 1
and assignedTo
->collect(completionDate <> Undefined)
->size() < 3
)
viii. If the status of a submission is Completed then the submission
must be linked to a completion date and at least three reviews must
be available. (5 pts)
context Submission
inv EnoughCompletedReviews:
status = Completed implies (
assignedTo
->collect(completionDate <> Undefined)
->size() >= 3
)
b. (15 pts) Define the following query operations using the OCL.
i. Return all the reviewers assigned to a paper that completed their
reviews in 14 days or less (i.e., the duration from the review
assignment date to the review completion date is 14 days or less).
(5 pts)
Assumption: “a paper” means “a specific paper”
context Paper
def onTimeReviewers() : Set(Reviewer) =
assignedTo->select(
revassignmentDate.duration(completionDate) <= 14
)->collect(reviewer)
ii. Return all the reviewers assigned by an editor who have not yet
completed a review. (5 pts)
context Editor
def: getReviewNotComplete(): Set(Reviewer) =
EdAssignments
->collect(assignees)
->select(completionDate == Undefined)
->collect(reviewer)
iii. Return the number of papers assigned to an editor for which the
duration between the editor assignment date and the reviewer
assignment date is 2 days or less for ALL the paper’s reviewer
assignments. (5 pts)
context Editor
def: getOnTimeAssignment(): Integer =
EdAssignments->select(
assignees
->collect(paper)
->select(
assignedTo
->forAll(
assignedEd.duration(revassignmentDate) <= 2
)
)
)->size()
Download