Anda di halaman 1dari 3

ASSIGNMENT # 1

SOFTWARE ARCHITECTURE & DESIGN

SUBMITTED TO: Maam Rafia Mumtaz SUBMITTED BY : Usman Ali Khan REG. # NUST-2010-BESE1B-272 Dated: 2/03/2012

Q1.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. ANSWER: It should exhibit content coupling because minClassSize & maxClassSize are declared as public and many different classes are accessing them and they can be modified very easily unless they are declared as private data members.

(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. ANSWER: It exhibit inclusion coupling as no. of classes and utility tools are imported.

(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 ANSWER:It should exhibit content coupling as four variables are declared as public data members. Moreover no. of classes can access them. It also exhibit Stamp coupling as Address is also used as an argument in methods. Q2.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 SUPERCLASS: Shape POLYMORPHIC OPERATIONS: Void Draw( ) Float area( ) Void GetParameters( ) Circle class have a function of int get_radius( ) function which will get the radius of the circle to be drawn.while Void GetParameter( ) will get the parameters of remaining shapes. (b) Truck, Ambulance, Bus SUPERCLASS: Vehicle POLYMORPHIC OPERATIONS: Void get_passengers( ) Void get_FuelConsumption( ) All the classes inherit the above funtions except ambulance which will use Void NoOfPatients( ) instead of Void Get_passengers.

(c) Technician, Administrative Assistant, Manager SUPERCLASS: Staff POLYMORPHIC OPERATIONS: Void set_duties( ) Void get_workingHours( ) Void get_PayPerHour( ) All the classe inherit above mentioned function while manager class have an extra function of Void Managing( ).

Q3.Which of the following would not form good superclasssubclass pairs (generalizations), and why? (a) Money Canadian Dollars: It will form a good pair as Canadian dollar is a type of money. (b) Bank Account: No, Bank-account cant be a good pair for superclass-subclass pair as account is not a type of bank. Moreover operations in bank cant be used in account. (c) Organization Unit Division: yes, they form well an example of generalization. (d) Saving Account Checking Account: No its not a good idea to declare this pair as superclass-subclass pair because of the fact that both of them are types of accounts. In fact Account class can be used as a superclass for both of them. (e) Account Account12876: No its not a good pair because account12876 is in fact an instance of the class and account12876 is not the type of the account but it is the name of the account. (f) People Customer: Yes they form a good pair. Customers are actually people and operations of people class can also be present in the customer class. (g) Student Graduate Student: Yes they form a good pair because graduated student is a type of student and can inherit some common functions. (h) Continent Country: No, its not a good idea to form a pair of these two as superclasssubclass as country is not inheriting anything from continent. (i) Municipality Neighborhood: Yes these two form a good pair because there is a lot common between these two and neighborhood cant inherit many things from municipality.

Anda mungkin juga menyukai