Developer Log - TerminalOS
Project Overview
TerminalOS is an interactive CLI simulation designed to mimic a basic Unix-like environment inside a standard console. The development focused heavily on shifting from unstructured procedural code to a robust object-oriented architecture, improving data persistence stability, and refining user interaction.
What Was Achieved
OOP Architecture Conversion
The entire codebase was refactored into a centralized TerminalOS class. Instead of passing state manually through disparate functions or relying on unsafe global variables, the application now encapsulates its configuration, user profiles, and runtime loops inside dedicated class properties (self.state, self.user, self.running).
Scalable Menu Navigation (Dictionary Dispatch)
To avoid messy, nested if/elif/else blocks inside the main user loop, a dictionary dispatch pattern was implemented in the desktop interface. By mapping user selection keys directly to object methods, the code remains clean, readable, and easy to extend with new features in the future.
Defensive Error Handling and State Recovery
Recognizing that sudden terminal closures frequently cause JSON files to corrupt, the state loading mechanism was hardened. The system explicitly traps json.JSONDecodeError and ValueError during startup. If a bad file is detected, it logs a warning cleanly to sys.stderr and drops back to a safe default payload, preventing hard system crashes.
Input Sanitization and Quality-of-Life Patches
Local validation testing revealed edge-case bugs, such as accidental whitespace entry skipping password validation. This was patched by applying .strip() to user string inputs and adding fallbacks for empty names. Additionally, the Matrix rain visual effect was updated with a customized mixed-ASCII charset to move away from overused open-source tropes.
Technical Debt & Next Steps
- The hardware diagnostics panel currently uses static, hardcoded placeholder data. This needs to be converted to dynamic readouts using standard library utilities to keep the project dependency-free.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.