Welcome to my blog!

Code Refactoring

June 10, 2020 15:58

Code Refactoring (edit)

Tools: https://marketplace.visualstudio.com/items?itemName=cmstead.jsrefactor

JavaScript in Plain English



https://www.oreilly.com/library/view/refactoring-javascript/9781491964910/ch01.html (HAY)

What Is Quality and How Does It Relate to Refactoring?

There have been countless efforts to determine what makes for quality code. Some are determined by collections of principles:

  • SOLID: Single responsibility, open/closed, Liskov substitution, interface segregation, and dependency inversion
  • DRY: Don’t repeat yourself
  • KISS: Keep it simple, stupid
  • GRASP: General responsibility assignment software patterns
  • YAGNI: Ya ain’t gonna need it

Flowing from that, our tactical concerns are to write tests for code, and write code that is easily testable. Here I not so humbly introduce the EVAN principles of code quality:

  • Extract functions and modules to simplify interfaces
  • Verify code behavior through tests
  • Avoid impure functions when possible
  • Name variables and functions well

What Is and Isn’t Refactoring

Before we leave off, let’s once again distinguish between refactoring and other lookalike processes. Here is a list of things that are not refactoring. Instead, they create new code and features:

  • Adding square root functionality to a calculator application
  • Creating an app/program from scratch
  • Rebuilding an existing app/program in a new framework
  • Adding a new package to an application or program
  • Addressing a user by first and last name instead of first name
  • Localizing
  • Optimizing performance
  • Converting code to use a different interface (e.g., synchronous to asynchronous or callbacks to promises)




C# 2.0 Code Refactoring


Rename a code symbol refactoring



Recent posts