@manhng

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://medium.com/javascript-in-plain-english

https://www.sitepoint.com/javascript-refactoring-techniques-specific-to-generic-code/

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)

https://www.freecodecamp.org/news/javascript-code-cleanup-how-you-can-refactor-to-use-classes-3948118e4468/

https://levelup.gitconnected.com/3-javascript-refactoring-techniques-for-clean-code-c356be1abbcb

https://dev.to/pieohpah/how-i-refactor-my-code-47cc

C# 2.0 Code Refactoring

https://www.codemag.com/article/0401071/C

Rename a code symbol refactoring

https://docs.microsoft.com/vi-vn/visualstudio/ide/reference/rename?view=vs-2017

Categories

Recent posts