Module 8: Object-Oriented Design in Practice
Mini-Project: Shape Toolkit
Build a small shape system that combines abstraction, composition, and polymorphism in a practical way.
Author
Java Learner Editorial Team
Reviewer
Technical review by Java Learner
Last reviewed
2026-04-17
Java version
Java 25 LTS
Learning goals
- Apply abstract classes and interfaces together
- Use composition for rendering behavior
- Design a small system that stays open to extension
Project goal: Create a Shape abstraction with area() plus render support for different output styles such as text or SVG-like strings.
Suggested design: Use an abstract Shape base type for shared fields, concrete classes like Circle and Rectangle, and a separate renderer interface for output behavior.
What to practice: Constructor design, overriding, polymorphism, and composition all belong here.
Success check: You should be able to add a new shape or a new renderer with minimal edits to existing code.
Runnable examples
A clean split between shape and renderer
interface ShapeRenderer {
String render(String label);
}
class TextRenderer implements ShapeRenderer {
@Override
public String render(String label) {
return "Rendering " + label;
}
}Expected output
A renderer can change output style without changing the shape hierarchy.
Mini exercise
Implement `Circle` and `Rectangle`, then add a second renderer that outputs bracketed labels such as `[Circle]`.
Summary
- The project should combine inheritance and composition for a clear reason.
- Renderer behavior should stay separate from shape math.
- This is your first intermediate design exercise, not just a syntax drill.
Next step
The next module shifts from design structure to error handling, resource safety, and debugging.
Sources used