Living Museum of Learning

Small circles, Big thinkers 🌱
Ivy’s Star Function: From Hardcoding to Composition

Ivy’s Star Function: From Hardcoding to Composition

A night of engineering thinking: building, breaking, and reconstructing a “star” on the chessboard grid

Ivy was assigned to write a function that draws a “star” on a Chinese chessboard grid using code. She came to class without completing the homework, and we decided to build it together from scratch in real time.

The key moment came when Ivy realized that the hardcoded numbers (4, 1) were actually just placeholders for x and y. She understood that refactoring is not mechanical replacement, but intentional abstraction—and saw her star “move” correctly once parameters were truly applied.

She progressed from a hardcoded drawing function to a fully parameterized one, then improved structure by introducing intermediate variables (sX, sY), renaming for clarity (col, row), and finally decomposing the star into composable parts (halfStarL / halfStarR). The function evolved into a composed system rather than a monolith.

Hardcoding → Parameterization
Repetition → Abstraction
Long expressions → Named intent
Large function → Composition
Refactoring is a cognitive act, not a mechanical one
Meaningful structure emerges through iterative redesign