Skip to content

Instantly share code, notes, and snippets.

@joebew42
Last active March 9, 2020 10:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joebew42/0ff621459779d0e7c1058f87dae3cea2 to your computer and use it in GitHub Desktop.
Save joebew42/0ff621459779d0e7c1058f87dae3cea2 to your computer and use it in GitHub Desktop.

Takeaways from TDD and Software Design

video

  • TDD by its own CANNOT leads to good design, obviously
  • TDD as a mechanism to help us to learn more about good design
  • Software is "Soft" just because it can be changed, it is not meant to be settled in the stone
  • Test-first programming can help the team to reduce defects but it will not lead to good design

Code qualities

Practice 5: Create CLEAN Code

  • Cohesive
  • Loosely coupled
  • Encapsulated
  • Assertive
  • Nonredundant

Good code is CLEAN code

Simple design

  • Passes its tests
  • Reveal its intent
  • Minimize duplication
  • Has fewer elements

When a test is not a unit test

source

  • It talks to the database
  • It communicates across the network
  • It touches the file system
  • It can't run at the same time as any of your other unit tests
  • You have to do special things to your environment (such as editing config files) to run it.

Test Desiderata

Desiderable properties of good tests, by Kent Beck and Kelly Sutton

Qualities of Unit Tests

  • Fast
  • Isolated
  • Repeatable
  • Self-validating
  • Timely

TDD cycle

  • Red: Write a failing test
  • Green: Make the test pass as fast as possible
  • Refactor: Take a look at your code

The Twelve-Factor App

source

  • One codebase tracked in revision control, many deploys
  • Explicitly declare and isolate dependencies
  • Store config in the environment
  • Treat backing services as attached resources
  • Strictly separate build and run stages
  • Execute the app as one or more stateless processes
  • Export services via port binding
  • Scale out via the process model
  • Maximize robustness with fast startup and graceful shutdown
  • Keep development, staging, and production as similar as possible
  • Treat logs as event streams
  • Run admin/management tasks as one-off processes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment