Skip to content
Back to projects
Cover
Case study

Java debugging & refactor (Heme Biotech)

Java debugging & refactor (Heme Biotech)

Debugging and fixing a Java application for medical needs prediction at Hemebiotech.

Context

Heme Biotech ("Remedies for those we love"), a pharmaceutical company specializing in blood disorders, had assigned Alex, a chemistry researcher, to build a small Java trend-analysis tool: read a symptom file and output each symptom's count, alphabetically sorted. Alex got stuck with a counter that always returned 0. Caroline, CTO and co-founder, handed the rest to an incoming dev intern: diagnose the bug, refactor to Java OOP standards, and document everything in Javadoc for team handover.

Problem Scope

  • Symptom counter consistently returning 0, regardless of the actual number of occurrences in the file (e.g. 3 occurrences of "headache" → 0 in the output)
  • Monolithic code with no separation of concerns between reading, counting and writing
  • No interfaces or OOP patterns in place
  • Naming not compliant with Java camelCase conventions
  • No Javadoc documentation available for team handover

Solution & Deliverables

  • Bug fixed via TreeMap.merge() aggregation: a single data structure handles both exact counting and native alphabetical ordering — no separate sort step needed
  • Reading delegated to ReadSymptomDataFromFile, implementing the ISymptomReader interface (getSymptoms())
  • Writing encapsulated in WriteSymptomDataToFile, implementing ISymptomWriter
  • AnalyticsCounter refocused on 2 responsibilities: countSymptoms() (TreeMap aggregation) and writeSymptoms() (output file generation)
  • Entry point isolated into a dedicated Main class orchestrating read → count → write
  • camelCase naming applied throughout the entire codebase
  • Full Javadoc on all public methods
  • result.out file generated with alphabetically sorted symptoms and exact counts

Stack & Technologies

  • Java 8+ — primary language
  • TreeMap — data structure for natural ordering and accurate counting
  • Java Interfaces — ISymptomReader, ISymptomWriter
  • Javadoc — automated code documentation
  • Git — dev → main workflow, atomic commits per step
  • IntelliJ IDEA — development environment

Project Timeline

  1. 1
    Analysis & diagnosis
    Code review, bug identification (TreeMap logic), mapping of OOP violations
  2. 2
    Bug fix
    Replaced broken counter logic with TreeMap for correct counting and natural ordering
  3. 3
    OOP refactor
    Interfaces created, classes separated, camelCase naming applied throughout
  4. 4
    Documentation
    Full Javadoc written for all public methods
  5. 5
    Validation & delivery
    Manual testing, result.out generation, defense validated with 2/2 skills

Defense Results

2/2
Skills validated
1 critical
Bugs fixed
4
Classes created
2
Interfaces

Screenshots

Screenshot 1