Thread: Pseudocode

  1. #1
    Registered User
    Join Date
    Sep 2015
    Location
    Australia
    Posts
    63

    Pseudocode

    Hi all..

    In the forum I read now and then about using pseudocode, I am curious as to which code is used and is it something you use on a regular basis.
    I have never used such a thing , the only help I have used is the good ol Flowchart..sometimes I need this to help me work through loops within loops and such but is usually done on an whiteboard next to my table here, no computer version.
    Thinking of expanding to flowcharts for the whole program development as I do fnd the visual much more easy to follow.


    John

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Well it's all kind of the same. The point of recommending pseudo code is to get you thinking logically about the execution without worrying about syntax and meaning of the target language. The benefit of pseudo code is that the lines in almost English are usually easy to follow, and if you drill down enough the steps are simple to write in the target language.

    Whatever other tools you have will do the same in different ways, and they have their place. Flow charts are very visual and work well for those who need to see and not "read" per se.

  3. #3
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    I personally find that flow charts and pseudo code come in handy for different things.

    For instance, if I'm designing code where a lot of decisions must be made, a flow chart helps me "map out" the logic visually.

    On the other hand, if I need to determine a set of consecutive steps (where few decisions are required) to achieve a solution, I like to write out each step in English (pseudo code) until I'm sure the logic makes sense. Then I go through and convert each step into corresponding code.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    On a practical note, I prefer using pseudocode here: I have no patience and limited skill at creating flow charts that would be attached to my posts!
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    On another practical note I will sometimes write very vague/broad pseudocode as comments in source code (e.g. if I only have a general idea how I might implement something, or it's something I know how to do but for whatever reason decide to defer implementing it). These comments either: become functions; stay as comments (maybe with re-wording); or get deleted -- whichever is appropriate -- when I actually implement the "pseudocode".

    I am using the term pseudocode fairly loosely here; I don't mean detailed pseudocode that lays out every step but more like, I don't know, "general pseudocode"

  6. #6
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    I am using the term pseudocode fairly loosely here; I don't mean detailed pseudocode that lays out every step but more like, I don't know, "general pseudocode"
    yeah generally the closer to natural language pseudo code is, the more of a bird's eye view it is, so multiple steps could be expressed as one line. makes it harder to translate directly into code, but experienced people don't often need detail that fine-grained.

    I realized I haven't explained where I use what tool. Personally, I tend not to reach for flow charts - they are hard to draw. But their shape can highlight a logical mistake very quickly like what MutantJohn was saying. There have been ocassions here where I drew them, because it explains the problem.

    I tend not to use pseudo code as a development tool on purpose, but there have been situations where it was required (...homework). I tend to use charts and tables more thanks to my formal education on projects. They're more permanent.
    Last edited by whiteflags; 12-09-2015 at 12:14 AM.

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by whiteflags
    But their shape can highlight a logical mistake very quickly like what MutantJohn was saying.
    Matticus
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Quote Originally Posted by whiteflags View Post
    yeah generally the closer to natural language pseudo code is, the more of a bird's eye view it is, so multiple steps could be expressed as one line. makes it harder to translate directly into code, but experienced people don't often need detail that fine-grained.
    Yes, I think that is a pretty good description of what I mean. In many ways it's like a chart or a table but with words (and using more words), possibly also including constraints and conditions.

  9. #9
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    587
    Quote Originally Posted by Hodor View Post
    Yes, I think that is a pretty good description of what I mean. In many ways it's like a chart or a table but with words (and using more words), possibly also including constraints and conditions.
    Or Python ;-)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pseudocode help
    By oliversacks in forum Tech Board
    Replies: 13
    Last Post: 02-06-2013, 11:16 AM
  2. Pseudocode help
    By oliversacks in forum C++ Programming
    Replies: 3
    Last Post: 02-06-2013, 03:32 AM
  3. pseudocode help
    By dantheman4 in forum Tech Board
    Replies: 3
    Last Post: 09-29-2011, 06:19 PM
  4. Pseudocode ?
    By sarajko in forum C Programming
    Replies: 1
    Last Post: 11-19-2010, 06:40 AM
  5. help with pseudocode?
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 08-11-2002, 06:33 PM