Closed jhanarato closed 1 year ago
Starting with layout.py
:
Instead of calling draw()
on every component, just yield the x/y coordinates via __iter__
or another function. Only height()
and width()
so perhaps draw()
can be removed from ImageComponent
.
Changing components, including Countdown
does not look like it will cause any difficulties.
In compose.py
we should replace the call to layout.draw()
with a zip() of x/y and the component list we already have, then loop and call draw()
on each component.
In our tests:
test_countdown_component.py
can simply remove the None
draw parameters.test_layout.py
can ditch the LoggerComponent
and simply test the output of the iterator.In order to work in baby steps, create a new method draw_xxx()
, change everything over then rename back to draw()
. Thanks Mr Fowler.
Done, and it wasn't hard.
The best (?) way to get rid of the many draw objects I'm passing around is to pass the draw object when calling the draw method. Like this:
Then we don't need to pass it in when constructing the objects and our tests don't need to pass
None
all the time.