Midterm Project — Build a Real CLI Tool

মিডটার্ম প্রোজেক্ট — একটি বাস্তব CLI টুল তৈরি করুন

Effort: 6–10 hrs Milestone Pick 1 of 4 tracks GitHub submission

1. The Brief — Ship Something Real

You now know enough Java to write a complete program. This midterm project asks you to pick one of four tracks, build the tool end-to-end, push it to GitHub, and write a real README. Small but complete — that is the mantra. The goal is not a perfect tool; the goal is a tool that works and that you are comfortable maintaining.

এতদিনে আপনি পূর্ণ Java প্রোগ্রাম লেখার মতো জানেন। এই midterm-এ চারটি track থেকে একটি বেছে নিন, পুরো tool-টি বানান, GitHub-এ push করুন, এবং একটি ভালো README লিখুন। ছোট কিন্তু সম্পূর্ণ — এটাই মন্ত্র। লক্ষ্য — এমন একটি tool যা কাজ করে এবং আপনি নিজেই রক্ষণাবেক্ষণ করতে স্বচ্ছন্দ।
Why a CLI? A command-line tool forces you to think about input, output, error handling, persistence, and shipping — without GUI distractions. Every serious backend engineer has written many.

2. The Four Tracks — Pick One

Pick the track that excites you — all four are equally scored A · Todo Manager add / list / done persistent JSON priorities Classic & rewarding B · Weather CLI city → current HTTP client JSON parse Real API, real JSON C · Password Gen length, sets cryptographic RNG strength score Security-focused D · CSV Stats mean / median groupBy formatted output Data + streams Figure 36.1 — চারটি track — যেকোনো একটি বেছে নিন।

Track A — Todo Manager (কাজের তালিকা)

  • todo add "Buy rice" --priority high
  • todo list — pretty-printed table, sorted by priority
  • todo done 3 — marks task 3 complete
  • todo rm 3 — deletes task 3
  • Persist to ~/.todos.json. Create if missing.
কাজ যোগ করা, তালিকা দেখা, সম্পন্ন করা, মুছে ফেলা। ~/.todos.json ফাইলে সংরক্ষণ। first run-এ ফাইল না থাকলে তৈরি করবে।

Track B — Weather CLI (আবহাওয়া CLI)

  • weather Dhaka — calls a free weather API (e.g. Open-Meteo)
  • Uses Java 11 HttpClient — no external HTTP library
  • Parses JSON (Jackson, Gson, or hand-rolled)
  • Prints temperature, feels-like, humidity, and tomorrow's forecast
  • Caches last response to ~/.weather-cache.json for 10 min
শহরের নাম নিয়ে API call করবে, current আবহাওয়া + আগামীকাল forecast দেখাবে। ১০ মিনিটের cache রাখবে।

Track C — Password Generator (পাসওয়ার্ড জেনারেটর)

  • pwgen --length 16 --upper --digits --symbols
  • Uses java.security.SecureRandom (never Math.random())
  • Reports a simple strength score (bits of entropy)
  • Option --count N to produce N passwords
  • Option --no-ambig to exclude ambiguous characters (O 0 I l 1)
length ও character set-এর flag নেয়, SecureRandom দিয়ে password বানায়, entropy হিসেব করে দেখায়।

Track D — CSV Stats (CSV পরিসংখ্যান)

  • csvstats sales.csv --col price
  • Computes count, min, max, mean, median, stddev for the chosen column
  • Uses streams and DoubleSummaryStatistics
  • --group-by region option prints per-group stats
  • Handles missing/invalid cells gracefully
CSV ফাইলের একটি column-এর পরিসংখ্যান বের করবে — count, min, max, mean, median, stddev। --group-by দিলে group-অনুসারে।

3. Project Structure and Starter Skeleton

Use Maven. Three to six classes. Below is a runnable skeleton that shows argument parsing, a sub-command dispatch, and a clean exit code on failure. It runs here in the sandbox.

Maven ব্যবহার করুন। ৩ থেকে ৬টি class। নিচে একটি runnable skeleton — argument parsing, sub-command dispatch, error-এ সঠিক exit code।
Main.java
class Main {
    public static void main(String[] args) {
        // simulate: todo add "Buy rice"
        String[] demo = { "add", "Buy rice" };
        int rc = dispatch(demo);
        System.out.println("exit code = " + rc);
    }

    static int dispatch(String[] args) {
        if (args.length == 0) {
            usage();
            return 2;
        }
        String cmd = args[0];
        return switch (cmd) {
            case "add"  -> add(args);
            case "list" -> list();
            case "done" -> done(args);
            default    -> { usage(); yield 2; }
        };
    }

    static int add(String[] a) {
        if (a.length < 2) { System.err.println("need a title"); return 2; }
        System.out.println("added: " + a[1]);
        return 0;
    }
    static int list() { System.out.println("(no items)"); return 0; }
    static int done(String[] a) { System.out.println("done"); return 0; }
    static void usage() {
        System.err.println("Usage: todo [add|list|done|rm] ...");
    }
}

4. Deliverables Checklist

ItemRequiredবাংলায়
GitHub repo (public)yespublic GitHub repo
README.md with run instructionsyesrun instructions সহ README
Maven pom.xmlyesMaven build file
3–6 classes organized in packagesyes৩–৬টি class, package-এ organized
At least one unit test (JUnit 5)yesঅন্তত একটি JUnit 5 test
Proper exit codes (0 ok, 1 error, 2 usage)yesসঠিক exit code
Error messages to stderr, not stdoutyeserror System.err-এ
Short demo GIF or terminal screenshotrecommendedscreenshot/GIF (সুপারিশকৃত)
License file (MIT or Apache-2.0)recommendedLICENSE file (সুপারিশকৃত)

5. Rubric — How You Will Be Scored

CriterionPointsবাংলায়
Works end-to-end (no crashes on sample input)30end-to-end ঠিকমতো চলে
Code structure & naming15code structure ও নামকরণ
Error handling & exit codes15error handling ও exit code
Unit test present and passing10unit test থাকা ও pass হওয়া
Persistence / I/O correctness10persistence ও I/O সঠিকতা
README clarity10README-এর স্পষ্টতা
Polish (formatted output, flags, defaults)10polish — formatted output, flags
Submission: push the repo, then send the link via the course form. Aim for done, not perfect — a small working tool beats a big broken one.

6. Common Pitfalls to Avoid

⚠️ Mistakes graders see often

  • Putting everything in main — split into classes
  • Swallowing exceptions silently with empty catch
  • Printing errors to stdout instead of stderr
  • Hard-coded file paths that break on other OS
  • No README or a one-line README
  • Using Math.random() for password generation

✅ Habits that impress

  • A clean --help flag with usage text
  • Meaningful exit codes
  • README has a one-command "how to run"
  • Tests cover the core happy path
  • No mutable static state leaking between calls
  • A tiny demo GIF in the README

7. Vocabulary

TermMeaningবাংলায়
CLICommand Line Interface — text-only program driven by arguments.argument-চালিত text program।
Exit codeInteger a program returns to the OS; 0 = success.OS-কে ফেরত দেওয়া status (০ = success)।
stdout / stderrStandard output stream / standard error stream.standard output / error stream।
PersistenceStoring state across program runs (file, DB).একাধিক run-এ state টিকিয়ে রাখা।
Unit testA small automated test of a single unit of code.কোডের ছোট অংশের স্বয়ংক্রিয় test।
READMEProject's front-page documentation.project-এর প্রথম documentation।

8. The Project

Your single "practice problem" for this module is the project itself. Pick a track, build it, push it. Use the checklist above as a live TODO list.

এই module-এ একমাত্র কাজ — project-টি নিজেই। একটি track বেছে নিন, বানান, push করুন। উপরের checklist-কে TODO হিসেবে ব্যবহার করুন।
  1. Midterm Project: Build and ship one of the four CLI tools (Todo, Weather, Password, CSV Stats). Fulfil the deliverables checklist, meet the rubric, and submit the GitHub link.
    মিডটার্ম প্রোজেক্ট: চারটি CLI-এর একটি বানান এবং ship করুন (Todo, Weather, Password, CSV Stats)। Deliverables checklist পূরণ করুন, rubric-এ pass করুন, GitHub link জমা দিন।
    Example submission layout (উদাহরণ)
    todo-cli/
    ├── pom.xml
    ├── README.md
    ├── LICENSE
    └── src/
        ├── main/java/com/abcl/todo/
        │   ├── Main.java           ← argument dispatch
        │   ├── TodoService.java    ← business logic
        │   ├── TodoStore.java      ← JSON persistence
        │   └── Todo.java           ← data record
        └── test/java/com/abcl/todo/
            └── TodoServiceTest.java

    README skeleton:

    • What it does (2 sentences)
    • How to build: mvn package
    • How to run: java -jar target/todo.jar add "Buy rice"
    • Example session (copy-paste terminal)
    • Tech used (Java 21, Maven, JUnit 5)
    • License

    উপরের structure অনুসরণ করুন — আলাদা file-এ business logic, persistence, data class। README-তে এক command-এ কীভাবে চালাবেন সেটা দিন।

Summary — Module 36 · Midterm

The midterm exists to prove to yourself that you can ship a complete Java program, not just run snippets in a browser. Pick the track that excites you, follow the deliverables checklist, and submit a link that a stranger could read and run. This is the habit of a professional engineer.

Midterm-এর উদ্দেশ্য — নিজের কাছে প্রমাণ করা যে আপনি snippet-এর বাইরে একটি সম্পূর্ণ Java প্রোগ্রাম ship করতে পারেন। যে track আপনাকে আকর্ষণ করে সেটা নিন, checklist মেনে চলুন, এমন link জমা দিন যা অচেনা কেউ পড়ে চালাতে পারবে। এটাই professional engineer-এর অভ্যাস।

Next Module → Phase 9 শুরু — Thread ও Runnable।