Professional Documents
Culture Documents
Assignment 02:
Design Principles
Announcement Date
3rd December 2020
Due Date
10th December 2020 11:59 PM on LMS
(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