Skip to content

Latest commit

 

History

History
10 lines (7 loc) · 679 Bytes

File metadata and controls

10 lines (7 loc) · 679 Bytes

Task 1/2: What is Extract Variable refactoring?

A magic number is a numerical value used in the code without a comment explaining its purpose. Using magic numbers in code is considered bad practice because it makes the code prone to errors and less maintainable and readable.

To resolve this problem, you can press the &shortcut:IntroduceConstant; (macOS) or Ctrl+Alt+C (Windows/Linux) shortcut to create a constant variable with a meaningful name and use it in the code.

If there are duplicated values in the code (string values or just lines of code), you can use the &shortcut:IntroduceVariable; (macOS) or Ctrl+Alt+V (Windows/Linux) shortcut to introduce a variable.