Thread: pseudocodes

  1. #1
    Registered User
    Join Date
    Dec 2006
    Location
    Jacksonville, AR
    Posts
    91

    Smile pseudocodes

    Hi everyone..

    I was wondering, does anybody has any tips or pointers on how to effectively write pseudocodes??

    Thanks in advance and a happy new year to all!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well for really big projects, you'll need something like UML to sketch out the relationships between the major components of your system. A lot of UML is only applicable for certain kinds of problems, so don't feel weird about only using a couple (out of the dozen or so) of diagrams. It doesn't even need to be that formal, even a couple of rough sketches could be very useful.

    I aim to pitch one line of pseudo-code would expand to 5 to 10 lines of actual code. Don't go into too much detail in the first instance, you can always refine later. If you have more than 5 lines of pseudo code for a function (25-50 real lines of code), then perhaps you need to split that up into separate functions as well.

    For a group of related functions solving some particularly complicated algorithm, you might want to include more detail in a discussion format, or site references to books/the web.

    Also be wary of going into too much detail. If you want to sort something, then just say
    "sort the data", rather than trying to list all the actions of say quicksort. You're just going to use the library code anyway, so no need to labour the point.

    When it comes to writing the code, it should look like this
    Code:
    /* Line of pseudo explaining the purpose of the function */
    int aFunc ( type param ) {
        /* Line of pseudo */
        ...
        ...
        ...
        ...
        ...
        /* Line of pseudo */
        ...
        ...
        ...
    }
    That is, your pseudo-code should form the inline block comments of your actual code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pseudocodes
    By Yoshi in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 11-19-2002, 01:17 PM