Notice
Recent Posts
Recent Comments
Link
«   2026/01   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

Visual Studio

프로그래밍 하면서 자주 할법한 실수 3가지 본문

Computer Engineering

프로그래밍 하면서 자주 할법한 실수 3가지

emacser 2025. 6. 4. 18:03

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' 카테고리의 다른 글

Intrusive Linked List vs Extrusive Linked List  (0) 2026.01.13
멱등성(Idempotency)  (0) 2024.07.16
소스 코드와 코드베이스의 차이  (0) 2024.06.14
[C++] lambda의 static 선언에 대하여  (0) 2024.04.22
Language Server  (0) 2024.01.16