M206 - TMA06 - Question 4
(a) (i) Oversees
Association type |
Oversees |
Direction and multiplicity |
The association is navigated from Administration to AcademicStaff. The multiplicity is one with respect to Administration, and many with respect to AcademicStaff. |
Class table to be modified |
Administration |
Additional variable in Administration |
|
class table |
academicStaff -> Dictionary ('Name'-> anAcademicStaff 'Name'-> anAcademicStaff ) |
Justification
A Dictionary object is suitable here because an instance of the class Administration needs to be able to quickly locate Academic Staff given their Names. The Names are unique, so the keys are unique. A dictionary does not have a fixed size, so as many Academic Staff as needed can be added. It does not appear to be necessary to keep track of the order in which Academic Staff are added, so an ordered collection class is not necessary.
(ii) Takes
Association type |
Takes |
Direction and multiplicity |
The association is navigated from Student to Course. The multiplicity is many with respect to Course, and many with respect to Student. |
Class table to be modified |
Student |
Additional variable in Student |
|
class table |
courses -> Set ('aCourse, aCourse, aCourse) |
Justification
A Set object is suitable here because an instance of the class Student needs to be which three courses the student is taking this term. An Array object could have bee used here but is a FixedSize Collection which would inhibit expansion should the rules change sometime in the future and a student be allowed to take more than three courses.
(iii) Tutors
| Association type |
Tutors |
Direction and multiplicity |
The association is navigated from Course to Tutor. The multiplicity is many with respect to Course, and many with respect to Tutor. |
Class table to be modified |
Course |
Additional variable in Course |
|
class table |
tutor-> aTutor |
Justification
Since the relationship between Course and Tutor is one to one when navigated in this direction all that is required is a simple instance variable in Course
(iv) Counsels
Association type |
Counsels |
Direction and multiplicity |
The association can be navigated in both directions Student to Counsellor and vice-versa. The multiplicity is one with respect to Counsellor,'and many with respect to Student. |
Class table to be modified |
Student |
Additional variable in Student |
|
class table |
counsellor -> aCounsellor. |
Class table to be modified |
Counsellor |
Additional variable in Counsellor |
|
class table |
students -> Set (aStudent, aStudent ) |
Justification
A Set object is suitable here because an instance of the class Counsellor needs to be able to quickly list the students associated with a particular Counsellor instance. A FixedSize Collection is definitely ruled out here as the negotiated statement clearly says "a counsellor counsels typically 10 - 12 students.
(b) Encapsulation is the basis for reusable software components. For an object to be encapsulated its internal structure is available to the object itself, but is not available to any other object. That is to say, an object cannot directly reference the instance variables of another object. Objects encapsulated when they respond only to messages in their protocol.
It is important to respect encapsulation during the design and implementation process so that the integrity of the system can be guaranteed. If the barrier between an object's protocol and its internal structure is breached, it means that other objects have access to the internal structure without using the objects' protocol and thus can change the objects' state without it knowing.
Encapsulation is not enforced in SmallTalk, it is the responsibility of the software developers (analysis's, designers & programmes) to decide how encapsulation is enforced in their software.