pseudocodes

This is a discussion on pseudocodes within the C++ Programming forums, part of the General Programming Boards category; Hi everyone.. I was wondering, does anybody has any tips or pointers on how to effectively write pseudocodes?? Thanks in ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,540
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 12:17 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21