Spiral 6 – some finishing touches
A working program always gives its developer a sense of joy, and rightfully so. However, this doesn't mean you can leave the code as it is. On the contrary, carefully review your code for some time to see if there is room for improvement or optimization. For example, are the names you used clear enough? The color of a hidden cell is now named simply COLOR_CODE
in board.dart
, renaming it to HIDDEN_CELL_COLOR_CODE
makes its meaning explicit. The List
used in the Cells
class can indicate that it is a List<Cell>,
by applying the fact that Dart lists are generic. The parameter of the
every
method in the Cell
class is more precise—it is a function that accepts a cell and returns bool
. Our onMouseDown
event handler contains our game logic, so it is very important to tune it if possible. After some thought we see that the code from the previous spiral can be improved; in the line below the second condition after &&
is in fact unnecessary:
if (cell...