This project is a Java implementation of the Mine Pump system, following the Real Object-Oriented (OO) approach described by Carlo Pescio. Instead of using a centralized controller, the design distributes responsibilities across collaborating objects, allowing for better modularity, testability, and maintainability.
The Mine Pump system is responsible for managing water levels in a mine while ensuring safety from gas hazards. The system consists of:
- Water Level Sensors: Determines when to pump water out of the sump.
- Gas Sensors: Monitors carbon monoxide, methane, and airflow.
- Pump: Removes water when necessary but cannot operate under unsafe conditions.
- Siren: Triggers warnings when gas levels become critical or the pump fails.
The challenge is to implement this system without a monolithic controller, ensuring that each object encapsulates its own behavior.
The project is structured into several key classes:
BasicSumpProbe
– Determines when pumping is required.GasSensor
– Evaluates gas safety levels.SafeEngine
– Ensures the pump operates only when conditions are safe.GasAlarm
– Triggers alerts when hazardous conditions arise.SumpPump
– Manages the actual pumping process.MinePlant
– Acts as a factory/builder to configure and instantiate the system.
To run the project, compile the Java files and execute the main entry point. Since this implementation focuses on a true OO design, it can be easily extended to integrate with actual hardware or simulations.
- Carlo Pescio’s article on Life without a Controller: Original Post
This application follows these four fundamental principles:
- No
null
(why?) - No code in constructors (why?)
- No getters and setters (why?)
- No mutable objects (why?)
- No
static
methods, not evenprivate
ones (why?) - No
instanceof
, type casting, or reflection (why?) - No implementation inheritance (why?)
- No public methods without
@Override
- No statements in test methods except
assertThat
(why?)
If you want to know more about true object-oriented programming, I recommend these books: