2134 F24 Assignment4
2134 F24 Assignment4
Fall 2024. Due date: 11:59pm, Friday, November 29, 2024, submitted via Git
Objectives
Extend an existing code-base and perform some basic class-level refactoring in the process.
Preparation:
Clone the Assignment 4 repository
https://git.cs.dal.ca/courses/2024-fall/csci-2134/assignment4/????.git
where ???? is your CSID.
Problem Statement
Take an existing codebase, add required features, test your features, and
Background
The CacheSim application is ready to move on to version 2! Now that all the bugs are fixed, it’s
time to add some new features, as requested by the client. Your boss has hired you to extend the
code. She will provide you with (i) the “bug free” codebase, (ii) the existing code specification,
and (iii) the requirements of the additions to be made.
Your job is to (i) create a design for the additions, (ii) implement the additions, and (iii) create
unit tests for the additions, while following good development practices. This includes: proper git
usage, writing comments/documentation, writing unit tests, and doing regression testing. This
assignment is meant to emulate how you might work and implement features in the real world.
Note1:
Although these classes and code are very similar to Assignment 3, this is a standalone assignment. You
do not need to “import” your unit tests or bug fixes from Assignment 3. Everything you need is included
directly in the Assignment 4 repo. Simply use the unit tests and existing code provided.
Note2:
It’s a good learning exercise to compare the bug fixes you completed in Assignment 3 to the code
provided in Assignment 4. Look to see if you missed any bugs. Compare the way you fixed the
bugs versus the way the bugs are fixed in the Assignment 4 code. Good questions for self reflec-
tion are: Are the two fixes for the same bug different? Which fix do you like better? Why?
Tasks
0. Follow these tasks in sequence to achieve the best results!
1. Review the old specification (specification.pdf) in the docs directory of the repo.
You will absolutely need to understand it and the code you are extending.
2. Review the new requirements at the end of this document, which describes all the extensions
to be performed.
4. Once Feature #1 is implemented and tested, merge it into the main branch.
6. Once Feature #2 is implemented and tested, merge it into the main branch.
7. Provide a readable, professional looking UML diagram of your final implementation. This in-
cludes both pre-existing classes and any classes you added to implement the extensions.
a. You do not need to include protected methods, private methods, or getter/setter
methods in the UML diagram.
b. There are a lot of online tools available to draw UML diagrams. Creately, draw.io,
canva, miro, and lucidchart are all great options.
c. Commit your UML diagram as design.pdf in the docs directory of the repository.
Make sure you’re committing on to the main branch.
Submission
All extensions and files should be committed and pushed back to the remote Git repository.
Grading
The following grading scheme will be used:
Task 4/4 3/4 2/4 1/4 0/4
The same as (3/4) PLUS: Each feature is im- Branches are not Fewer than two No
each feature branch con- plemented on its adequately tested branches are branches
tains multiple commits own branch. before merging. used. are used.
Git Usage
showing implementation Branches are tested
(10%)
and testing process. before merging.
Branches are
merged into main.
Diagram accurately re- Diagram accurately Diagram mostly re- UML class dia- No UML
flects the implementa- reflects the imple- flects the imple- gram generally diagram
tion. All necessary rela- mentation. Most mentation. Most reflects the im- pro-
tionships and class at- relationships and relationships and plemented de- vided.
UML
tributes are correctly in- class attributes are class attributes are sign. Only some
(10%)
cluded. Diagram is neat correctly included. correctly included. relationships
and professional. Diagram is not very and class attrib-
well organized or utes are cor-
legible. rectly included.
Code looks professional Code looks good Code occasionally Code does not Code is
Code Clarity and follows style guide- and mostly follows follows style guide- follow style illegible
(5%) lines style guidelines lines guidelines or not
provided
Code is thoroughly docu- Code is mostly doc- Code is partly docu- Code is barely No code
mented, including ID umented. A few pa- mented. Roughly documented. docu-
Documenta- blocks for new classes rameters, returns, half of the ex- Most ID blocks menta-
tion and documentation for or ID blocks are not pected details are are missing. tion.
(10%) new methods. sufficiently docu- missing. Most methods
mented. are not docu-
mented.
Before implementing this feature, we notice that the Cache class itself is currently responsible
for accessing the backing store to read and write data. This does not follow the Single Responsi-
bility Principle. We will begin by first encapsulating interaction with the backing store and then
extending its functionality to include timing.
Where the cache item is installed depends on its key: the index to install the cache item is the
key modulo the cache capacity. For example, in a cache with capacity 4:
• key 2 would be installed in index 2 ( 2 % 4 = 2 ).
• key 18 would be installed in index 2 ( 18 % 4 = 2 ).
• key 23 would be installed in index 3 ( 23 % 4 = 3 ).
CacheSimMain must also be updated now to ask the user for which type of cache they would
like to simulate. Ask the user which cache they would like to simulate and receive their choice
using System.in. Users should input “L” for the pre-existing least-recently used cache or “D”
for the direct-mapped cache. The program should continue to ask for the user’s choice until a
valid choice is given. (Hint: see the mailbox example in the defensive programming slides.)
Non-Functional Requirements
1. All methods and classes should be thoroughly documented.
2. Code should consistently follow good coding practices and style guidelines.