↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

10 Refactorings to Boost your Clean Code Skills

The article presents refactoring as a gradual way to improve code: small changes make complicated code easier to understand, and repeated small steps can reveal better structure. It frames the main tools as ways to extract pieces, move them, rename them, or update signatures so the code matches what it does.

Reading notes
#

  • Extract Variable when an expression is too long or needs a concept with a name.
  • Extract Function when a function grows too large or holds too many responsibilities.
  • Extract Parameter when a value should be passed in instead of coming from internal state.
  • Extract Type Definition when a props list becomes hard to read or needs reuse in TypeScript.
  • Slide Statements to group related statements and make the file read more smoothly.
  • Change Function Declaration when behavior changes and the name no longer matches what the function does.
  • Change Variable when a placeholder name can be replaced by a clearer one after the code becomes more explicit.
  • Move the Fields / Constants when moving code to another file makes the current file shorter and easier to read.
  • Inline Variable when an extracted variable is no longer useful and the reverse change is better.
  • Change Signature when parameters need to be reordered, added, removed, or retagged.
  • Use IDE shortcuts to find available refactorings or search for actions when the right command is unclear.
  • The summary says these refactorings are the most commonly used ones to master for restructuring complicated code.