582334 TDD-ohjelmointimenetelmä ja koodin suunnittelu (5 op), syksy 2009
582334 TDD programming technique and designing code (5 cr), autumn 2009

Kurssiesittely Luennot Harjoitukset

Exercise 2: Tetris #2-3 (emerging algorithms, refactoring). Naming variables.

Tetris project work

See the instructions in the first exercise.

Homework

max 6 points

  1. Refactor this project's class nineplaces.Diagram so that its variables and methods have better names. In this class, almost all non-public members have been renamed (the last two methods, index and contains, have not been changed). Use the Rename refactoring of your IDE and refactor the class until all of its names make sense. (The structure of the methods does not need to be changed. Just renaming will be enough.) Print the end result of your refactoring on paper so that it would be easier to discuss it in the exercise group.

    You can get instructions for choosing good names from the Clean Code book's chapter 2 or the article Meaningful Names.

    1 point: Half of the method and variable names have been named sensibly. All tests pass.
    2 points: All of the method and variable names have been named sensibly. All tests pass.

  2. Tetris #2-3: Implement code to pass RotatingPiecesOfBlocksTest and RotatingTetrominoesTest using TDD. The test cases have been provided, so you need to just remove their comments one at a time, as you manage to write production code to pass the tests.

    1 point: All previous tests pass and out of RotatingPiecesOfBlocksTest's 6 tests 3 pass.
    2 points: All previous tests pass and out of RotatingPiecesOfBlocksTest's 6 tests 6 pass.
    3 points: All previous tests pass and out of RotatingTetrominoesTest's 12 tests 5 pass.
    4 points: All previous tests pass and out of RotatingTetrominoesTest's 12 tests 12 pass.

In the exercise group we will discuss about naming variables, pair program starting from Tetris #4 and do the challenging refactoring in its beginning. If the refactoring goes too easily, refactor also your pair's version.


Viimeksi muokattu 01.12.2010 21:04 Copyright © 2009 Esko Luontola