Skip to content

Code-quality polish: dead code, debug leftovers, doc stubs, minor robustness #7

Description

@jonfroehlich

Problem

A cluster of small polish items surfaced during a code-quality review. None is urgent, but collectively they affect how clean the library reads as teaching material. Tracking them together.

Code hygiene

  • Dead member: GraphLine::_sampleTotal is declared and honestly commented "unused currently" (GraphLine.hpp). Remove it rather than ship documented dead state.
  • Commented-out debug Serial.printlns left in source: FileUtils.hpp (the "ends with"/"does NOT end with" lines) and Shape.hpp ("We are in overlaps shape!"). A published library should be clean of these.
  • Empty Doxygen stubs: several @param/@return lines have no text and read as auto-generated boilerplate (e.g. Shape::distance params; Circle::overlaps @return true/@return false; many graph getters). Fill or drop them.

Robustness

  • MovingAverageFilter has no guard on windowSize. Doc says "must be > 0" but new int[windowSize] and getAverage()'s / _windowSize will misbehave for 0/negative. Add a guard or at least an explicit "undefined if <= 0" note.
  • ScrollingLineGraph buffer sizing _bufferSize = _widthGraph - _xGraph; has no guard against width < xGraph (negative allocation). Low real-world risk.

Teaching-code consistency

  • Shape::distance uses pow(dx, 2) — on AVR that's a slow float call; dx*dx + dy*dy is faster, exact, and a nice teaching point. Called per-frame in circle collisions.
  • CollisionTest.ino never delete[]s _targetShapes. Harmless on a microcontroller (lives for program lifetime) but, in code that explicitly demonstrates new, model the cleanup rule taught elsewhere.
  • Example footers (Pong.ino, CollisionTest.ino, others) still use the old @jonfroehlich style, not the shared footer the .hpp headers adopted — finishes the footer-alignment work.

Repo niceties (optional)

  • Add CHANGELOG.md (releases are now versioned — 0.2.0).
  • Add CONTRIBUTING.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions