4 min read

My Personal Guide to Write Pseudocode

Table of Contents

My Go-To Pseudocode Style

Sometimes I like to think the clarity and structured way before writing actual code implementation. To achieving this is by writing pseudocode. It’s a simple, yet powerful to outline the logic without being tied up with the programming language rules. Over time, I developed a few rules and habit to make it easy to follow and have a concise writing standard-whether when I’m working alone or sharing it with others. Here’s how I like to write it:

1. Indentation to Keep Things Neat

I’m a fan of readable code, so I always use indentation to show the structure of my pseudocode. For me, it just make it more readable because indents show where one idea ends and another begins. This is especially helpful with loops, conditionals, and nested logic.

IF condition    
    ...
    
    IF anotherCondition THEN
        ...
    END IF
ELSE
    ...
END IF

2. All Caps for Keywords

I write all the keywords in capital letters to make it easy to spot the key parts of my pseudocode. Making the words like IF, THEN, ELSE, FOR, WHILE, RETURN, FUNCTION, END, and other keyword stand out, so I’m not confuse within the reserve keyword or variable name.

FUNCTION CalculateTotal
    READ numbers

    INITIALIZE total = 0
    
    FOR each number IN numbers
        total = total + number
    END FOR
    
    RETURN total
END FUNCTION

3. Simple and Clear Variable Names

I like to keep my variable names straightforward and descriptive, so anyone reading the pseudocode can immediately understand what each variable purpose is for. I usually stick with camelCase or snake_case, depending on the situation.

SET totalPrice = basePrice + taxAmount

4. Minimalist Data Structures

When I need to show a list, array, or dictionary, I like to use simple notations. Using [] for lists or array and curly braces {} for key-value pairs. But I only pull these out when I really need them to make things clear.

SET points = [89, 79, 81, 100, 94]
SET courseDetail = {name: "Programming 101", credits: 3}

5. Functions and Procedures

When my pseudocode involves a block of logic, I use the FUNCTION keyword. I clearly list any parameters with the READ keyword and what the function returns or accomplishes with RETURN.

FUNCTION FindMaxNumber
    READ arrayInput

    INITIALIZE max = arrayInput[0]
    FOR each item IN arrayInput
        IF item > max THEN
            SET max = item
        END IF
    END FOR
    
    RETURN max
END FUNCTION

6. Closing Structures

For every loop, conditional, or function structure in my pseudocode has a matching END keyword. This helps avoid confusion by making it clear where each block of logic begins and ends.

WHILE condition THEN
    ...
END WHILE

FOR i FROM 1 TO n
    ...
END FOR

IF condition THEN
    ...
ELSE
    ...
END IF

7. Comments to Clarify

I try to make my pseudocode self-explanatory, but for some reason sometimes a little extra explanation is needed. I use comments (preceded by //) to clarify tricky parts or explain why I made a particular decision. I keep these sort and to the point.

averagePoint = totalPoint / numberOfStudents

// NOTES: Check if the average point is above the threshold
IF averagePoint > passingPoint THEN
    PRINT "Pass"
ELSE
    PRINT "Fail"
END IF

Conclusion

By sticking to these simple rules, I make sure that my pseudocode is easy to read and understand. Whether I’m working in personal or collaborating with a team, this approach helps me keep my thoughts organized and clear.