Visual Studio
프로그래밍 하면서 자주 할법한 실수 3가지 본문
1. for문에서 continue 대신 return 사용
for (int32 i = 0; i < NumElements; ++i)
{
if (Elements[i] > 0)
{
// continue로 처리해야할 로직
return;
}
}
2. Guard Clause 패턴에서 !나 == false 누락
if (IsValid(Object)) /* !IsValid(Object) 혹은 IsValid(Object) == false 이어야 할 로직 */
{
return;
}
3. Array 등의 컨테이너 타입을 리턴 타입, 파라미터로 사용할 때 & (Refenrece) 누락
const TArray<FMyElement> GetMyElements() const { return MyElements; }
// 리턴 타입에 "&" 누락
void ProcessElement(const TArray<FMyElement> InElements);
// 함수 파라미터에 "&" 누락
'Computer Engineering' 카테고리의 다른 글
| 멱등성(Idempotency) (0) | 2024.07.16 |
|---|---|
| 소스 코드와 코드베이스의 차이 (0) | 2024.06.14 |
| [C++] lambda의 static 선언에 대하여 (0) | 2024.04.22 |
| Language Server (0) | 2024.01.16 |
| Sementics Versioning (0) | 2022.08.25 |