Devlog 3 — Persistence and Control (File-based History + Clear Command)
What I learned:
- Why CLI programs reset completely every time they are executed
- How to use the
fsmodule to write and read files in Node.js - How
appendFileSynccan be used to store data incrementally - How to read stored data using
readFileSync - The difference between in-memory state and persistent state
- How small bugs (like variable naming or extra trims) can break logic in subtle ways
- Why validation, execution and side effects (like saving history) should stay separated
Biggest struggle:
This part was less chaotic than Day 2 but still frustrating in a different way.
The logic itself wasn’t the problem this time. It was understanding how programs behave over time. I had already built a history system before so seeing it disappear every run was confusing at first.
Then came the file system part. Writing to a file felt simple but reading it back properly and formatting it without breaking things took more effort than expected. Small mistakes like misnaming variables or structuring loops incorrectly kept causing issues.
It wasn’t overwhelming chaos but more like constant small friction that slowed everything down.
Current features:
- Persistent history system using
fs - Calculations are stored in
history.txtacross runs -
historycommand displays formatted past calculations -
clearcommand wipes stored history clean - Improved validation and error messages
- Clean separation between parsing, validation and execution
Next steps:
- Convert the calculator into an interactive CLI (REPL-style)
- Reduce repeated validation logic into reusable helpers
- Improve overall UX (cleaner outputs and command feedback)
Reflection:
The biggest realization was understanding that programs don’t remember anything unless you explicitly store it. That changed how I think about state completely.
Compared to earlier struggles, this one felt quieter but still tiring. Less confusion, more persistence. Fixing small issues, understanding behavior and slowly making things more stable.
It still isn’t perfect but it finally feels like the calculator has some sense of continuity instead of resetting every time.
Note: The screenshot does not show all features (full validation system).
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.