When is your code done? When you finish the refactor refactor refactor rule.


Since unit test cases should be written before the actual code, you cannot say that code is done when the unit test all pass.

You need the RRR rule.

  1. Legibility (Readability)
    1. Code that runs on and one in a single function that spans a whole page of print is too much. Refactor the function calls down to clean testable segments.
  2. Code duplication (Repetitiveness)
    1. Code segments that show up more than once, need to be wrapped into a function call and unit tested on their own.
  3. Performance optimization (Run Time)
    1. Try moving your child functions to stateless static functions. Also look at how you may recycle or preserve state from prior child functions, to prevent rebuilding the wheel with every child call.
    2. Note that I don’t call this runtime, which is a state of coding vs running, but Run Time, as in the time for your code to complete running through a task.

There is a 4th R, Resource… Your team members are a resource for you, and you for them. Do code reviews that focus on refactoring. Call them refactor views.

1 Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.