Case Study

Zelda Like Remake

Refactoring a Java game with the implementation of Design Patterns.

JavaJavaFX

01 — The Remake Context

Often, in a learning curriculum, the first functional projects hide a chaotic source code (“Spaghetti code”). This project consisted exactly of taking an old Zelda Like game previously developed (in Java) and restructuring it from scratch.

The objective was not to add features, but to prove our ability to improve the maintainability of the source code, optimize game performance, and above all introduce professional standards.

Illustration du projet
The new, clean, and modular project directory structure

02 — Separation of Concerns (MVC)

The Initial Problem: The old classes mixed graphical display (JavaFX), business logic (health points, damage), and keyboard controls. This strong coupling made any evolution dangerous.

The Solution: We implemented the Model-View-Controller (MVC) architecture. Game data (the Model) was completely separated from the visual rendering loop (the View). Keyboard inputs were offloaded to a dedicated Controller, making the code testable and understandable.

Illustration du projet
Example of logical extraction: Before (top) / After (bottom)

03 — Behavioral Flexibility (Design Patterns)

In the old version, each type of enemy manually redefined its own movement logic via huge conditional blocks (if/else or switch).

Using the Strategy Design Pattern, we encapsulated the movement algorithms into distinct and interchangeable object classes. Similarly, the Decorator Pattern was used to manage character statistics (application of armor or weapons) in a stackable manner, without modifying the base player class. Finally, the Singleton ensures the uniqueness of the Game Manager.

Illustration du projet
Implementation of Patterns to avoid code duplication

04 — Results on Code Clarity

This 4-person team effort highlighted the vital importance of continuous Refactoring. By applying SOLID principles, the code became not only shorter but it also “tells” what it does. The future addition of a new enemy or a new weapon will only require creating a single small class, with no risk of breaking the game engine.

Illustration du projet
Cleaning a heavy class: the code becomes short, readable, and expressive