You are on page 1of 2

SoICT STRUCTURED PROGRAMMING - FINAL EXAM

HUST
Duration: 75’ Course ID: IT4492E
Documents are not allowed

Student full name: …………………………………….

Student Id: ………………Exam Id: ………………… Exam date: ……….......

Question 1. Good software design has high cohesion and low coupling. Briefly explain the
meaning of this idea.

Question 2. What is a design pattern? Present one design pattern and indicate when that design
pattern should be used.

Question 3. Point out the code smells in the code shown below. Then briefly describe what
refactoring steps you would take to refactor the code.
Note: You don’t need to write down the refactored code, it’s sufficient if you say how you
refactor the code to remove the code smells.

public class Product


{
String productName;
double price;
String type;

//constructor, getters and setters

public String printInfo()


{
return productName + ": " + price + "đ\n";
}

public class Order


{
int orderNumber;
List<Product> productList;

public String orderInfo()


{
String s = "ORDER " + orderNumber + "\n";
for (Product p : productList)
{
if (p.type == "TAXFREE")
s += p.productName + ": " + p.price + "đ\n";
else if (p.type == "LUXURY")
s += p.productName + ": " + p.price * 1.15 + "đ\n";
else
s += p.productName + ": " + p.price * 1.1 + "đ\n";
}
return s;
}
}

Page 1/2
Question 4. The bakery chain Bread King plans to develop (from system analysis to operation
testing) the website for selling bread and cakes online to customers and to form the new whole
system as follow:

Decompose the bakery selling website using three approaches: functional, algorithmic, and
object-oriented.

Page 2/2

You might also like