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.

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.

Advertisements
This entry was posted in Brian's Code Extreme, C#, C-Langs, JavaScript, NO SQL, PL-SQL, SQL, T-SQL. Bookmark the permalink.

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

  1. Pingback: Why are Open Source projects treated as 2nd class citizens when it comes to healthy computing? | Brian By Experience

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 )

Google+ photo

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

Connecting to %s