Red-Green-Code

Deliberate practice techniques for software developers

  • Home
  • About
  • Contact
  • Project 462
  • CP FAQ
  • Newsletter

About

duncan

About Me

Hi, I’m Duncan Smith. I live with my wife and our two kids near Seattle, WA, USA. I joined a software consulting company after college, and my first project was in the Seattle area. After a few years with no fixed address (hooray for the consulting life), I decided to move here permanently. Since then, I have worked in software development at various companies, mainly in the Windows/.NET world. I’m currently working at a large software company which I shall not mention here, but you know where to look if you’re curious. :-)

In 2015, I started this blog about deliberate practice techniques for software developers.

About RedGreenCode

Some software developers use a process called test-driven development (TDD), in which they write automated unit tests at the same time as they write their product code. One way to remember how the TDD process works is “red-green-refactor.” Here’s what each piece of that hyphenated term means:

  • Red: the developer writes a unit test which is intended to exercise a missing feature, or reproduce a bug. Since the feature hasn’t been written, or the bug hasn’t been fixed, the test should fail. Test runners generally indicate this with a red icon or status message.
  • Green: the developer implements the feature or fixes the bug and runs the test again. The test runner should display a green icon or message. Yay!
  • Refactor: although the code now works, it probably isn’t as elegant as it could be. Refactoring means “improving the design of existing code.” By running the automated unit tests, the developer verifies that the refactoring process didn’t break anything.

Can something like red-green-refactor be applied to developers’ brains as well as to the code that they’re writing? In learning theory, active recall is a way to find out what you know, and also to consolidate information in your memory. The active recall process requires a prompt or question and an answer provided by the learner. Consider a developer learning a new programming language. One way to do this is to implement small programs based on a prompt an an expected result. For example, the prompt could be “Calculate the first 100 prime numbers” and the expected result could be the first 100 prime numbers, one per line. Rather than test-driven development, we now have learning-driven development (LDD). The analogous term to red-green-refactor is red-green-code:

  • Red: to verify the developer’s knowledge of a concept, an automated test can be run against their code. A red result means the result of the programmer’s code doesn’t match the expected result. This is common early in the learning process.
  • Green: when the developer can successfully write code to generate the expected result, the test passes.
  • Code: after a green result, the developer has a bit more coding knowledge, which he or she can use in future coding projects.

The active recall approach is especially suited to learning programming, since computers are good at comparing actual and expected results. I’ll be writing more about how to apply this approach. Stay tuned.

Stay in the Know

I'm trying out the latest learning techniques on software development concepts, and writing about what works best. Sound interesting? Subscribe to my free newsletter to keep up to date. Learn More
Unsubscribing is easy, and I'll keep your email address private.

Getting Started

Are you new here? Check out my review posts for a tour of the archives:

  • 2022 in Review: Content Bots
  • 2021 in Review: Thoughts on Solving Programming Puzzles
  • Lessons from the 2020 LeetCode Monthly Challenges
  • 2019 in Review
  • Competitive Programming Frequently Asked Questions: 2018 In Review
  • What I Learned Working On Time Tortoise in 2017
  • 2016 in Review
  • 2015 in Review
  • 2015 Summer Review

Archives

Recent Posts

  • LeetCode Tip 11: How To Use Spaced Repetition (Part 1) March 22, 2023
  • LeetCode Tip 10: Planning a Spaced Repetition Schedule March 15, 2023
  • Book Review – Algorithmic Thinking: A Problem-Based Introduction, Second Edition March 9, 2023
  • LeetCode Tip 9: Spaced Repetition March 8, 2023
  • LeetCode Tip 8: Anatomy of a Model Solution March 1, 2023
  • LeetCode Tip 7: How to Write a Model Solution February 22, 2023
  • LeetCode Tip 6: Model Solutions February 15, 2023
  • LeetCode Tip 5: Choosing a Model Problem February 8, 2023
  • LeetCode Tip 4: Model Problems February 1, 2023
  • LeetCode Tip 3: A Goal for LeetCode Practice January 25, 2023
Red-Green-Code
  • Home
  • About
  • Contact
  • Project 462
  • CP FAQ
  • Newsletter
Copyright © 2023 Duncan Smith