0% found this document useful (0 votes)
36 views2 pages

Software Architecture Design Principles

This document provides details for Tutorial 1 of the course WIF3004 (Software Architecture and Design Paradigms) including: 1. A description of collections and their types (indexed vs non-indexed, allowing duplicates or not). 2. An example code snippet with CalTaxRate and ProductTaxRate classes and questions about identifying and reducing coupling between the classes. 3. Another example code snippet with a YearlyReport class handling multiple responsibilities and questions about how to improve its cohesion.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views2 pages

Software Architecture Design Principles

This document provides details for Tutorial 1 of the course WIF3004 (Software Architecture and Design Paradigms) including: 1. A description of collections and their types (indexed vs non-indexed, allowing duplicates or not). 2. An example code snippet with CalTaxRate and ProductTaxRate classes and questions about identifying and reducing coupling between the classes. 3. Another example code snippet with a YearlyReport class handling multiple responsibilities and questions about how to improve its cohesion.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

WIF3004 (Software Architecture and Design Paradigms)

Semester 2, Session 2019/2020

Tutorial 1
1. Draw an abstraction hierarchy from the following given information.
A collection is a group of any type of objects. Collections can be categorised
based on two aspects, namely, indexing or non-indexing of objects, and
duplication or non-duplication of objects. The four constructors used generally
in object-oriented databases, namely set, bag, list and multilist are considered
as collections. Sets and bags are non-indexed collections, while lists and
multilists are indexed collections. Bags and multilists allow duplicates while sets
and lists do not.

2. Cohesion and coupling give impact to the quality of a software design for which a
good design should be loosely coupled and highly cohesive.

a. Given the following code snippet:

class CalTaxRate {
float rate;
float rateForRegion() {
ProductTaxRate ptr = new ProductTaxRate();
rate = [Link];
}
}
class ProductTaxRate {
public float productRate;
public float adjustedProductRate;
public float getProductRate(String reg) {
productRate = new CalTaxRate().rateForRegion();
return adjustedProductRate;
}
}

i. Identify and locate the types of coupling it may have in the


abovementioned code. Give your comments and justification.

ii. How should the above-mentioned code be rectified and further


enhanced to minimize coupling and maximize cohesion? Provide a
complete loosely coupled code.
b. It is said the cohesion indicates the degree to which a class has a single,
well-focused purpose. As such the higher the cohesion, the better is the
software design.

Given the following code snippet:


class YearlyReport {

void connectToRDBMS() {

}
void generateYearlyReport() {

}
void saveToFile() {

}
void print() {

}
}

i. Why do you think that the above code does not provide a highly
cohesive class design?

ii. How can the above class design be improved to produce a highly
cohesion class design? Illustrate your answer by modifying the code,
and explain why you think that your answer provides a highly
cohesive class design.

You might also like