0% found this document useful (0 votes)
196 views

Structured Programming Exam 20211

This document outlines a final exam for a structured programming course. It contains 4 questions: 1) explaining high cohesion and low coupling in software design; 2) describing a design pattern and when to use it; 3) identifying code smells in a provided code sample and describing refactoring steps; and 4) decomposing a bakery website system using functional, algorithmic, and object-oriented approaches. The exam is 75 minutes and documents are not allowed.

Uploaded by

Thuận Bùi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
196 views

Structured Programming Exam 20211

This document outlines a final exam for a structured programming course. It contains 4 questions: 1) explaining high cohesion and low coupling in software design; 2) describing a design pattern and when to use it; 3) identifying code smells in a provided code sample and describing refactoring steps; and 4) decomposing a bakery website system using functional, algorithmic, and object-oriented approaches. The exam is 75 minutes and documents are not allowed.

Uploaded by

Thuận Bùi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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