Rename Variable - Refactoring skills(7)

Kerem Song·2021년 3월 23일
0

Refactoring - Study

목록 보기
9/22

7. Rename Variable(변수 이름 재 지정)

Make shared variable's name can self-explain
(변수 자체의 이름만으로도 무슨 일을 하는 지 설명할 수 있어야 함)

let a = height * width

to

let area = height * width

Procedure

  1. If this variable is used widely in your code,
    Try to make it to encapsulate variable
    폭넓게 쓰이는 변수라면 변수 캡슐화하기를 고려한다.

  2. Find all the places that reference the variable you want to rename and change them one by one.
    이름을 바꿀 변수를 참조하는 곳을 모두 찾아서 하나씩 변경한다.

  3. Test it.
    테스트 한다.

profile
Tea and Dessert

0개의 댓글