This repository contains a template for C++ based assignements in the 'Software Architecture' course. The template provides a CMake-based build system that makes it easy that makes it easy to build and test the students code.
The intention is to use this template as the seed project to several other repos, specifically one for each assignment in the course. An assignement in GitHub classroom provides the students with the appropriate files.
To detect tampering with the grading file calculate the md5 checksum. The most portable way of doing this is using python:
python -c "import hashlib; print(hashlib.md5(open('autograde.py','rb').read()).hexdigest())"
The md5 checksum should be: 3fb245f0f15bf8b4aeb34e9b5adc1289
-- if it is not then the file has been modified, which may or may not be intentional.
In this exercise you will:
- Preliminaries; Installing Dependencies
- Install and familiarize yourself with Git
- Examine the Repository Template
- Automatic Grading
- Correct Code
- Run Automatic Grading Script
The project template and associated script dependes on the following programs being installed and added to your systems path variable. In practical terms this means that the program can be located from the command line. The easiest way to check whether a program is in the systems path is to attempt launching it from the command line.
For example to check if the python interpreter is installed:
python
Make sure the following programs are installed and can be accessed from the systems path:
On Ubuntu you can install these using:
sudo apt install build-essential cmake python3 git clang-tidy cppcheck python3
You may install an CMake integration in VSCode that makes it easier to build and debug you code. The 'CMake' and 'CMake Tools' are recommended.
There are many ways to install these and often the preferred way depends on the particular OS. The most general advice is reading the install instructions found at their respective webpages.
Git is a version control system that is used extensively in software development, that allows you to store code while maintaining a history of changes made previously. GitHub is a popular service that hosts repositories and provides additional services.
The first part of this exercise is to install and familiarize yourself with git to a point where you can download the assignment template and subsequently submit the finished assignment through Git. There are countless guides online on how to install and use Git, one of them being:
Clone the repository and code away. Focus on the basic commands: clone
, commit
, pull
, and push
.
For assignment you are provided a set of files that help you get started with the assignment.
The files are:
- CMakeLists.txt: build script similar to a makefile, but cross-platform
- autograde.py: python script for building and grading your submission
- .gitignore: defines which types of files should not be tracked by Git
Source and header files are stored in the respective folders:
- include: Contains C++ header files
- src: include C++ source files
A central goal of this course is to improve your ability to write high quality and 'correct' code. Part of this effort is an increased emphasis on systematic testing.
For each exercise you are provided a set of unit tests as part of the handout that can be run to verify which parts of your code works and which parts do not. To test your code run the autograde.py
script using python:
> python autograde.py
...
1: Test command: C:\Users\clega\Desktop\repos\270191U025-Software-Architecture-assignment-template\build\Debug\tests.exe
1: Test timeout computed to be: 10000000
1:
1: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1: tests.exe is a Catch v2.13.4 host application.
1: Run with -? for options
1:
1: -------------------------------------------------------------------------------
1: Addition
1: 0 + 1 is 1
1: -------------------------------------------------------------------------------
1: C:\Users\clega\Desktop\repos\270191U025-Software-Architecture-assignment-template\src\tests.cpp(16)
1: ...............................................................................
1:
1: C:\Users\clega\Desktop\repos\270191U025-Software-Architecture-assignment-template\src\tests.cpp(18): FAILED:
1: REQUIRE( sum(0, 1) )
1: with expansion:
1: 0
1:
1: ===============================================================================
1: test cases: 1 | 1 failed
1: assertions: 2 | 1 passed | 1 failed
1:
1/1 Test #1: usage_test .......................***Failed 0.02 sec
0% tests passed, 1 tests failed out of 1
Total Test time (real) = 0.02 sec
The following tests FAILED:
1 - usage_test (Failed)
INFO:.\autograde.py:Running Memory Checker
UpdateCTestConfiguration from :C:/Users/clega/Desktop/repos/270191U025-Software-Architecture-assignment-template/build/DartConfiguration.tcl
Cannot find file: C:/Users/clega/Desktop/repos/270191U025-Software-Architecture-assignment-template/build/DartConfiguration.tcl
Site:
Build name: (empty)
UpdateCTestConfiguration from :C:/Users/clega/Desktop/repos/270191U025-Software-Architecture-assignment-template/build/DartConfiguration.tcl
Cannot find file: C:/Users/clega/Desktop/repos/270191U025-Software-Architecture-assignment-template/build/DartConfiguration.tcl
Memory check project C:/Users/clega/Desktop/repos/270191U025-Software-Architecture-assignment-template/build
Memory checker (MemoryCheckCommand) not set, or cannot find the specified program.
Errors while running CTest
INFO:.\autograde.py:
#######################################################################################################
Final grade is: 0
grade = test_passed_fraction* 70 + memory_check_passed * 20 + static_analysis_passed * 10
0 = 0% * 70 + False * 20 + False * 10
#######################################################################################################
Having cloned the repository you are now ready to define the abstract and implement the abstract class.
- Look at the definition of the abstract class found in
queue.hpp
. Make sure that you understand the significance of thevirtual
and=0
keywords.
class Queue
{
public:
virtual void enqueue(int value) = 0;
virtual int dequeue() = 0;
virtual bool empty() const = 0;
virtual bool full() const = 0;
};
-
Implement the class using an integer array, see
queue_array.hpp
. -
Implement the class using an integer list, see
queue_linked_list.hpp
.
Do not modify the script in any way, a checksum is used to check the integrity of the file. Incorrect checksum ⟹ no pass.