Does TDD mean not thinking about class design?

前端 未结 8 1934
生来不讨喜
生来不讨喜 2021-02-06 01:17

I am making a role playing game for fun and attempting to use TDD while developing it. Many of the TDD examples I see focus on creating the test first, then creating objects tha

8条回答
  •  耶瑟儿~
    2021-02-06 02:04

    A balanced approach is the way to go.

    However, the balance is Driven by the need to test.

    You can map out the possible classes and hierarchy. But, you'll need to drive the design by (1) thinking about testability and (2) writing the tests before writing too much code.

    For your tests to even compile, you need some class definitions. They don't have to work, but they have to compile.

    In a few cases your class may be so simple, you actually write all (or almost all) of it first.

提交回复
热议问题