You are on page 1of 3

National University of Sciences & Technology

School of Electrical Engineering and Computer Science


Department of Computing

CS 812: Object Oriented Analysis and Design


Fall 2020
Class: MS-IT

Assignment 02:
Design Principles

Announcement Date
3rd December 2020

Due Date
10th December 2020 11:59 PM on LMS

Instructor: Dr. Rafia Mumtaz


Name: Abdul Basit Reg#: 327013 Class: MS (IT)
Instructions:
(a) Please write your name, Reg # and class above. Please provide your answer in the
space provided below
(b) Assignment must be submitted in PDF format
(c) Please adhere to the above instructions, otherwise marks will be deducted.
Question 1 [10 marks]
What is wrong with the following designs from the perspective of cohesion, and what could
be done to improve them?
(a) There are two subsystems in a university registration system that do the following.
Subsystem A displays lists of courses to a student, accepts requests from the student to
register in courses, ensures that the student has no schedule conflicts and is eligible to
register in the courses, stores the data in the database and periodically backs up the
database. Subsystem B allows faculty members to input student grades, and allows
administrators to assign courses to faculty members, add new courses, and change a
student registration. It also prints the bills that are sent to students.
(b) In an electronic commerce application, a module is created to add books to the ‘shopping
basket’ and perform such operations as computing the total amount the customer owes.
A second module adds ‘special reward’ merchandise to the shopping basket; this module
also displays the contents of the shopping basket on the screen and sends an email to the
user telling him or her what he or she bought.
Answer:
(a) Problem: The problem is in Subsystem B because functions for administration and
faculty both are in one system so there is weak functional cohesion.
Solution: There should be a separate class to manage data. And, should have separate
classes for faculties and administrators.

(b) Problem: The problem is that shopping basket is managed by both modules and also
merchandises and processing orders are managed in the same module so there is
weak functional cohesion.
Solution: There should be a separate class to manage the shopping basket. And, it
should have separate classes for selecting merchandises and processing customer

orders.

2|Page
Question 2 [10 marks]
Describe ways to reduce the cases of coupling in following systems.
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.
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.
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:
(a) As many modules (Student, Registration and University Administration) depends on
public class variables of CourseSection so it’s Type Use Coupling. We can reduce it by
declaring the variables as the most Generic type possible. E.g. we can have a separate
class as ClassSize which will have public methods for getting and setting minClassSize
and maxClassSize.

(b) As user interface class is importing different classes so there will be Inclusion / Import
Coupling. The only way to reduce this coupling will be to import only required classes.
Also, cross check that there is no conflict between class names i.e. you should not
declare a class with a name that conflicts with another imported class.

(c) As multiple classes are modifying the inner state of Address class (its public variables
constituting different parts of address) so there is Content Coupling. We can reduce this
coupling by declaring those four variables as “private” and use (getter, setter) methods
for these four variables.

3|Page

You might also like