How gracesong146/ip works
Project Type & Purpose
• This is a lightweight, greenfield Java command‐line application template.
• It models a simple task management tool (ToDo, Deadline, Event) with file‐based persistence and a text-UI test harness.
File Structure
• Top-level folders:
• src/main/java: application entry point and core classes (Cathy.java, Task, Storage, etc.)
• data: runtime task store (cathy.txt)
• docs: documentation for the project template
• text-ui-test: automated CLI input/output tests
• No external frameworks or microservices—just plain Java, file I/O, and JDK tooling.
Extract Insights from README
• Uses JDK17, plain Java.
• Entrypoint: Cathy.main() prints a banner and drives the application loop.
• Emphasis on keeping src/main/java as the code root (standard Gradle/IDE layout).
Main Components & Interactions
a. Application Layers/Components
1. Command-Line UI (Cathy.java): reads user commands, displays output.
2. Parser & Controller Logic (embedded in Cathy.java or helper methods): interprets user input, invokes domain operations.
3. Domain Model:
• Task (abstract)
• ToDo, Deadline, Event (subclasses)
• TaskType enum
• InvalidTaskTypeException for invalid command handling
4. Storage Layer (Storage.java): reads/writes data/cathy.txt to persist the list of tasks.
5. Data File (data/cathy.txt): the on-disk representation of current tasks.
6. Test Harness (text-ui-test): simulates CLI input, compares against EXPECTED.TXT to validate behavior.
b. Component Interactions
• UI captures raw input → Parser interprets into domain operations → Domain Model is created/modified → Storage persists updated model to file → UI prints success or error messages → Loop continues.
• On startup, Storage loads tasks from data/cathy.txt into in-memory model.
• On exit or after each command, Storage writes back to file.
• Test Harness injects input into the UI’s stdin and captures stdout for verification.
Architectural Patterns & Principles
• Layered Architecture (UI → Controller/Parser → Domain Model → Persistence).
• Single-Responsibility per class (each Task subclass only knows about its own fields; Storage only does file I/O).
• Open–Closed: new TaskTypes can be added by introducing new subclasses & updating enum without modifying existing code heavily.
• Thin main class (Cathy.java) that orchestrates modules rather than mixing concerns.
• Clear component names that match class/folder names
• Annotations for technologies (Java 17, file I/O)
• Boundaries: in-process vs. on-disk vs. external test harness