Você está na página 1de 4

Software Design & Architecture Assignment # 1

Question 1:
Categorize the following aspects of a design by the types of coupling they exhibit. (a) Class CourseSection has public class variables called minClassSize and maxClassSize. These are changed from time to time by the university administration. Many methods in classes Student and Registration access these variables. Content coupling (b) A user interface class imports a large number of Java classes, including those that draw graphics, those that create UI controls and a number of other utility classes. Import coupling (c) A system has a class called Address. This class has four public variables constituting different parts of an address. Several different classes, such as Person and Airport manipulate instances of this class, directly modifying the fields of addresses. Also, many methods declare one of their arguments to be an Address. Stamp coupling

Question 2:
For each of the following sets of classes, find an appropriate superclass and the polymorphic operations that should be included in this superclass. Explain the way these operations would behave in each subclass and identify some operations that might be present in only one of the subclasses. (a) Square, Circle, Rectangle Super class: Shape Polymorphic operation: Area Square: void area (int length) Circle: void area (int radius) Rectangle: void area (int length, int breadth) Number_of_line_segments/vertices () is a function which shall be present only in class Circle. (b) Truck, Ambulance, Bus Super class: Vehicle Polymorphic operation: Capacity Truck: capacity (char luggage_type, int number_of_luggage)

Ambulance: capacity (int number_of_patients) Bus: capacity (int number_of_passengers) Number_of_Nurses() is a function which shall be present only in class Ambulance. (c) Technician, Administrative Assistant, Manager Super class: Employee Polymorphic operation: Salary Technician: int salary (int Technician_id) Administrative Assistant: int salary (int AdministrativeAssistant_id) Manager: int salary (int Manager_id) Number_of_employees_working_under() is a function which is present only in class Manager. Expert_in() is a function which is present only in class Technician.

Question 3:
Which of the following would not form good superclasssubclass pairs (generalizations), and why? (a) Money Canadian Dollars (b) Bank Account * generalization doesnt hold between bank and account classes because they do not have is a relationship with each other i.e. Account is not a Bank. Account and bank have composition relationship. (c) Organization Unit Division (d) Saving Account Checking Account * generalization doesnt hold between saving account and checking account classes because they do not have is a relationship with each other i.e. Checking Account is not a Saving Account. These both are subtypes of Account class. (e) Account Account12876 * generalization doesnt hold between account and account12876 classes because they do not have is a relationship with each other i.e. Account12876 is not an Account. Account12876 is an instance of Account class. (f) People Customer (g) Student Graduate Student (h) Continent Country

* generalization doesnt hold between continent and country classes because they do not have is a relationship with each other i.e. Country is not a Continent. There is aggregation relationship between them. (i)Municipality Neighborhood * generalization doesnt hold between municipality and neighborhood classes because they do not have is a relationship with each other i.e. Neighborhood is not a Municipality.