[개발] 가독성 높은 코드를 위한 리팩토링 팁 4가지
Technical Debt
기술적 부채.
시간이 더 오래걸리는 더 나은 해결책을 선택하지 않고
쉬운 방식을 선택하여 재작업을 위한 추가적인 비용이 드는 것.
Refactoring
기존에 있던 코드 디자인을 향상시키는 기술.
1. Consistency 일관성 유지
들여쓰기(indentation)
괄호 위치(bracket position)
접근제한자 표시해주기 private, public
2. Convention 규칙 따르기
https://docs.microsoft.com/ko-kr/dotnet/csharp/fundamentals/coding-style/coding-conventions
C# 코딩 규칙
C#의 코딩 규칙에 대해 알아봅니다. 코딩 규칙은 코드를 일관되게 표시하고 코드 복사, 변경 및 유지 관리를 용이하게 합니다.
docs.microsoft.com
https://github.com/raywenderlich/c-sharp-style-guide
GitHub - raywenderlich/c-sharp-style-guide: C# Style Guide for Unity Tutorials
C# Style Guide for Unity Tutorials. Contribute to raywenderlich/c-sharp-style-guide development by creating an account on GitHub.
github.com
3. Bake your intent
코들르 함수의 기능을 이해할 수 있는 이름의 함수로 추출해서 호출
기능적인 부분이 좀 더 직관적으로 이해 됨.
4. Cut out the fat 필요 없는 것 제거
this 키워드의 사용 자제
주석 삭제
자체 문서화되는 코드를 작성할 것
스크립트에 관련되지 않은 기능의 함수는 따로 분리해서 정리할 것.