saury / refactoring-video-store-js

code following article refactoring-video-store-js by martin flowler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Refactoring

This is a code base for doing steps following the article refactoring video store js.

Flow chart

Flow chart

Instructions:

origin.js

This initial video store code is the js version of original example in 1st version Refactoring.

This statement function is an example of the smell Long Method.

decomposed.js

Decomposing the origin one into several functions:

parameter-dispatch

Specify the output format as an argument to the statement function by using Add Parameter,

top-level-fns

  • move nested fns to the top context. Deal with function that doesn't refer to any others 1st.

  • Declaring some partially-applied local functions

classes

  • wrap the data in objects
  • apply Move Method to function doesn't call any others

transform

  • add data middleware to transform the customer data structure so that it has all the data the printing functions need

Todo list:

  • Add unit test

About

code following article refactoring-video-store-js by martin flowler


Languages

Language:JavaScript 100.0%