Q1-6. Theory (20 marks)
Short-answer theory questions for this exam.
A few key phrases, dotpoints, or sentences is sufficient to score full marks in this section of the exam. Aim for concise and correct answers, more words does not mean more marks.
Question 1 (4 marks)
A system is designed that allows COMP1531 staff to view marks of the students in the course.
A requirement is given:
COMP1531 Staff are only allowed to view the project marks (not the exam marks).
In q1.md
:
- a) Is this requirement functional or non-functional? Justify your answer. (2 marks)
- b) Write a scenario-based acceptance criteria for this requirement. (2 marks)
Question 2 (4 marks)
Consider the following code:
function normalizeDay(d) {
if (d === "monday" || d === "Monday") return "monday";
else if (d === "tuesday" || d === "Tuesday") return "tuesday";
else if (d === "wednesday" || d === "Wednesday") return "wednesday";
else if (d === "thursday" || d === "Thursday") return "thursday";
else if (d === "friday" || d === "Friday") return "friday";
else if (d === "saturday" || d === "Saturday") return "saturday";
else if (d === "sunday" || d === "Sunday") return "sunday";
else return null;
}
function dayToMessage(d) {
if (d === "monday") {
return "It's Monday!";
} else if (d === "tuesday") {
return "It's Tuesday! Exam DAY";
} else if (d === "wednesday") {
return "it's the middle of the work week!";
} else if (d === "thursday") {
return "Almost friday...";
} else if (d === "friday") {
return "Rebecca who?";
} else if (d === "saturday") {
return "yay weekend!";
} else if (d === "sunday") {
return "almost monday :(";
} else {
return null;
}
}
function getMessageByDay(day) {
const normalizedDay = normalizeDay(day);
if (normalizedDay) {
const message = dayToMessage(normalizedDay);
console.log(message);
} else {
console.log("Invalid input. Exiting.");
}
}
getMessageByDay('monday');
getMessageByDay('Thursday');
In q2.md
:
- a) Justify which design principle is being violated. (2 marks)
- b) Refactor the application code to fix the violated design principle. (2
marks)
- You may add, modify, or remove the code as you'd like.
Question 3 (2 marks)
Consider this statement:
The user shall be able to change their password if they forget it.
In q3.md
, what part of the SDLC would you assume this statement was created in if you saw this statement written down on an engineering document? Justify your response.
Question 4 (2 mark)
Consider the following situation regarding how the Bobocup team structures their use of branches after migrating to GitLab:
Each new feature should reside in its own branch, which can be pushed to the central repository for backup/collaboration. When a feature is complete, it gets merged back into master via a merge request. Features should never be written directly on the master branch.
In q4.md
, justify one benefit of this process compared to everyone pushing all commits to master.
Question 5 (6 marks)
In q5.md
, explain the difference between:
- Continuous Integration,
- Continuous Delivery,
- Continuous Deployment,
Give an example of each.
Question 6 (1 mark)
Consider the following code:
function foo(flag) {
if (flag) {
console.log('Debug mode enabled');
}
let i = 0;
while (i <= 9) {
if (i % 3 === 0) {
console.log(i * 3);
} else if (i % 6 === 0) {
console.log(i * 6);
} else {
console.log(i * 9);
}
i++;
}
console.log("done");
}
In q6.md
, what is the cyclomatic complexity of the function foo()
?
Submission
When you've finished working, submit your answer by running:
submit --question <question no., or theory, or all>
# For example:
submit --question theory # To submit all theory questions
submit --question 3 # To submit a specific theory question
submit -q 3 # Shortenned
To see what you've submmited for a question, you can run:
submit --peek <question no.>
# For example
submit --peek 3
submit -p 3
To see a list of all submissions you've made, you can run:
submit --list
# or
submit -l
If no submissions have been made for a question, we will take the file from your working directory.