// Academic Project · Year 4

Advanced Software Engineering: Refactoring a Vehicle Simulator

Refactored a multithreaded Java simulator with the Strategy pattern and backed it with 16 new unit tests.

Systems & infrastructureJavaJUnitMavenDesign PatternsSOLIDUMLConcurrencyRefactoring

Coursework for Advanced Software Engineering. We were given VSim, a multithreaded Java simulator of autonomous vehicles, and asked to test it, fix a design flaw and map its architecture. Working my way through someone else's codebase like this is what got me thinking about Synergy.

The brief

Module
COMP5911M Advanced Software Engineering
Year
2025/26 · Year 4
Team
Individual
Weighting
50% of the module

VSim moves vehicles around a 2D grid. Each vehicle runs on its own thread and has to get exclusive access to a grid square before it moves into it. The coursework had three parts: improve the unit tests, fix a design problem in how vehicles choose their routes, and document the whole architecture as a UML class diagram.

Better tests

The existing checks for PathIntersection ran from a main() method and covered very little. I moved the project to Maven (Java 11, JUnit 4) and wrote 16 unit tests covering the cases that were missing: empty and null input, identical paths, paths that don't meet, one path inside another, negative coordinates, integer limits and duplicate points. All 16 pass.

Fixing the design

Applying the Strategy pattern

Every vehicle was hard-wired to the NorthFirst route finder. The simulator had other route finders, but using one meant editing the classes that created vehicles, which breaks the open/closed and dependency inversion principles.

I added a PathFinder interface that every route finder implements, and changed the scenario generator and Vehicle to depend on the interface instead of a concrete class. To show the change paying off, I added a RandomPathFinder that picks a strategy for each vehicle from a seed, without touching any other class.

Mapping the architecture

UML class diagram of VSim: Vehicle, Grid, Simulation, GridPanel, Logger, the PathFinder interface with its five implementations, and the test class.
My UML class diagram of VSim after the refactor, with the PathFinder interface and its implementations on the right.

Drawing this meant tracing every class and dependency through the code by hand. That's what led to Synergy: a tool that builds that map of a codebase automatically, so a developer or an AI agent can see how the pieces connect without reading every file.

Lab work

Alongside the coursework, the labs covered test-driven development and refactoring. One exercise refactored Fowler's video rental example two ways, with subclasses and with a pricing strategy, and compared the trade-offs.

Java JUnit Maven Design patterns SOLID UML Concurrency

Ask AI

answers from this site · DeepSeek

Starting assistant...