CSCI 2134 Assignment 4
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.
3. Implement, document, and test Feature #1.
a. Start by creating a new git branch feature1 on which to implement the feature. Commit as often as needed on this branch.
b. Implement the requirements as specified below. This includes creating a new Back- ingStore class and BackingStoreResponse class.
c. Create a BackingStoreTest class in the test directory and move the unit tests for fetchData() and pushData() into the new test class.
d. Modify the unit tests of fetchData() to also check that the correct timing is pro- duced. (You’ ll have to manually compute and then hard-code the expected timings)
e. Create a BackingStoreResponseTest class in the test directory and implement sufficient unit tests to test your new BackingStoreResponse class.
f. Add additional unit tests to CacheResponseTest to test the new methods added to CacheResponse.
g. Do regression testing. Ensure all unit tests pass. Ensure all input test cases pass. Note
that the GoldX.txt files now include the correct timing as well. h. Commit and push the feature branch!
4. Once Feature #1 is implemented and tested, merge it into the main branch.
5. Implement, document, and test Feature #2.
a. Start by creating a new git branch feature2 on which to implement the feature. Ensure that you are branching from main, and not from feature1. Commit as often as needed on this new branch.
b. Implement the requirements as specified below. This includes creating a new class DirectMappedCache.
c. Create a DirectMappedCacheTest class in the test directory and implement new unit tests. Each method to be tested requires several test cases. Use the test cases from CacheTest as a template. You should implement test cases for:
i. findData()
ii. evictData()
iii. getContents()
For brevity, you do not need to write unit tests for other methods.
d. Do regression testing. Ensure all unit tests pass. Ensure all input test cases pass. For TestX.txt as input, simulation with a direct-mapped cache should produce GoldX-DM.txt and simulation with a least-recently used cache should produce GoldX.txt.
e. Commit and push the feature 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.
8. Commit and push back everything to the remote repository.
a. Note: you really should be committing frequently throughout this assignment. Recall best practices for debugging, refactoring, and software development generally: make many small commits!