Drone Simulator: Design Refactor

The purpose of this project was to implement various code design patterns during each iteration of development.

Figure 1: Image of bus entity (in red)

This was a group project during the Spring 2022 semester in a course titled Program Design and Development. This project:

  • was iterated upon every week using the Agile Methodology.

  • introduced the basics of how to implement front end interfaces using HTML & CSS.

  • implemented various search algorithms & best practice design patterns.

This program utilizes a drone entity to pick up passengers one at a time to drop them off at specific locations. Throughout the semester we modified this code to make it better organized and designed. My group also decided to change the use of a drone entity to a bus entity, to then allow for transport of multiple passengers at once.

When running this program there are two main pages. The first page is a scheduler page (left). The next page is the simulation page (right).

FrontEnd Details

Design Refactoring #1: IEntityFactory Class

Since there were multiple entities such as the drone entity, robot entity, and bus entity, these would benefit from being stored in an EntityFactory.

The IEntityFactory class will now possess the fundamental characteristics of any entity which the DroneFactory class, RobotFactory class, and BusFactory class will now inherit from to create those specific entities.

Figure 4: This is the code for IEntityFactory class. The purpose of this image is to show that any entity created will now possess the same fundamental properties presented in the 2 virtual function calls (lines 11 & 12), inheriting from this base IEntityFactory class.

Design Refactoring #2: IStrategy Class

In order to optimize this code to allow expansion to more path algorithms, we created the IStrategy class which possesses fundamental properties of each path algorithm. This makes it easier to add new path algorithms as they all inherit the same properties.

Design Refactoring #3: CelebrationDecorator Class

The CelebrationDecorator class was used to spin the bus once it got to its destination. This decorator class was only applied to the movement that uses AStar, DFS, and Dijkstra strategy ultimately inheriting from the IStrategy class. The CelebrationDecorator class will check whether the movement is completed or not, and if it is completed, it will start to spin and celebrate.

We implemented the CelbrationDecorator class separately, to allow for easier implementations of extensions. In more detail, if the user wants to extend and add new search strategies, this CelebrationDecorator will automatically check whether the trip Iscompleted (line 9) for that new search strategy, since this CelebrationDecorator class is directly inheriting from the IStrategy class (line 5 on the right).

Live Simulation

Figure 8: This is a simulation of our program running in real time with all the above features.

Previous
Previous

SkinEasy: Web Application (Flask)