views:

932

answers:

14

Back in college, only the use of pseudo code was evangelized more than OOP in my curriculum. Just like commenting (and other preached 'best practices'), I found that in crunch time psuedocode was often neglected. So my question is...who actually uses it a lot of the time? Or do you only use it when an algorithm is really hard to conceptualize entirely in your head? I'm interested in responses from everyone: wet-behind-the-ears junior developers to grizzled vets who were around back in the punch card days.

As for me personally, I mostly only use it for the difficult stuff.

+4  A: 

I use pseudocode when away from a computer and only have paper and pen. It doesn't make much sense to worry about syntax for code that won't compile (can't compile paper).

Mark A. Nicolosi
That's not a bad rule of thumb.
Kyle Walsh
Compiling paper - Origami?
Treb
+7  A: 

I use it all the time. Any time I have to explain a design decision, I'll use it. Talking to non-technical staff, I'll use it. It has application not only for programming, but for explaining how anything is done.

Working with a team on multiple platforms (Java front-end with a COBOL backend, in this case) it's much easier to explain how a bit of code works using pseudocode than it is to show real code.

During design stage, pseudocode is especially useful because it helps you see the solution and whether or not it's feasible. I've seen some designs that looked very elegant, only to try to implement them and realize I couldn't even generate pseudocode. Turned out, the designer had never tried thinking about a theoretical implementation. Had he tried to write up some pseudocode representing his solution, I never would have had to waste 2 weeks trying to figure out why I couldn't get it to work.

Elie
+1  A: 

Mostly use it for nutting out really complex code, or when explaining code to either other developers or non developers who understand the system.

I also flow diagrams or uml type diagrams when trying to do above also...

KiwiBastard
+1  A: 

I generally use it when developing multiple if else statements that are nested which can be confusing.

This way I don't need to go back and document it since its already been done.

Brad8118
+1  A: 

Fairly rarely, although I often document a method before writing the body of it.

However, If I'm helping another developer with how to approach a problem, I'll often write an email with a pseudocode solution.

+2  A: 

I almost always use it nowadays when creating any non-trivial routines. I create the pseudo code as comments, and continue to expand it until I get to the point that I can just write the equivalent code below it. I have found this significantly speeds up development, reduces the "just write code" syndrome that often requires rewrites for things that weren't originally considered as it forces you to think through the entire process before writing actual code, and serves as good base for code documentation after it is written.

Robert Gamble
+1  A: 

I don't use pseudocode at all. I'm more comfortable with the syntax of C style languages than I am with Pseudocode.

What I do do quite frequently for design purposes is essentially a functional decomposition style of coding.

public void doBigJob( params )
{
    doTask1( params);
    doTask2( params);
    doTask3( params);
}
private void doTask1( params)
{
    doSubTask1_1(params);
    ...
}

Which, in an ideal world, would eventually turn into working code as methods become more and more trivial. However, in real life, there is a heck of a lot of refactoring and rethinking of design.

We find this works well enough, as rarely do we come across an algorithm that is both: Incredibly complex and hard to code and not better solved using UML or other modelling technique.

chris
There's definitely an allure to minimalist code (for me, anyways).
Kyle Walsh
+1  A: 

If I'm working out something complex, I use it a lot, but I use it as comments. For instance, I'll stub out the procedure, and put in each step I think I need to do. As I then write the code, I'll leave the comments: it says what I was trying to do.

procedure GetTextFromValidIndex (input int indexValue, output string textValue)
// initialize
// check to see if indexValue is within the acceptable range
//    get min, max from db
//    if indexValuenot between min and max
//       then return with an error
// find corresponding text in db based on indexValue
// return textValue
   return "Not Written";
end procedure;
thursdaysgeek
+1  A: 

I've never, not even once, needed to write the pseudocode of a program before writing it.

However, occasionally I've had to write pseudocode after writing code, which usually happens when I'm trying to describe the high-level implementation of a program to get someone up to speed with new code in a short amount of time. And by "high-level implementation", I mean one line of pseudocode describes 50 or so lines of C#, for example:

Core dumps a bunch of XML files to a folder and runs the process.exe
  executable with a few commandline parameters.

The process.exe reads each file
    Each file is read line by line
    Unique words are pulled out of the file stored in a database
    File is deleted when its finished processing

That kind of pseudocode is good enough to describe roughly 1000 lines of code, and good enough to accurately inform a newbie what the program is actually doing.

On many occasions when I don't know how to solve a problem, I actually find myself drawing my modules on a whiteboard in very high level terms to get a clear picture of how their interacting, drawing a prototype of a database schema, drawing a datastructure (especially trees, graphs, arrays, etc) to get a good handle on how to traverse and process it, etc.

Juliet
A: 

I never use or used it.

I always try to prototype in a real language when I need to do something complex, usually writting unit tests first to figure out what the code needs to do.

Fabio Gomes
+1  A: 

I and the other developers on my team use it all the time. In emails, whiteboard, or just in confersation. Psuedocode is tought to help you think the way you need to, to be able to program. If you really unstand psuedocode you can catch on to almost any programming language because the main difference between them all is syntax.

Ironsides
It may be true that most programming is done in languages that differ only in syntax. You can make that argument for C, C++, C#, Pascal, and Java. You can say it for Perl, Python, Smalltalk, Ruby, and maybe Scheme, depending on your level of macro kung-fu. You can group Basic, COBOL, and Fortran. And then there are outliers: Haskell, YACC, SQL -- they're programming languages all the same, but with unusual semantic patterns. That's what really makes a new language: semantics.
Ian
+1  A: 

I use it when explaining concepts. It helps to trim out the unnecessary bits of language so that examples only have the details pertinent to the question being asked.

I use it a fair amount on StackOverflow.

Alex B
+1  A: 

I don't use pseudocode as it is taught in school, and haven't in a very long time.

I do use english descriptions of algorithms when the logic is complex enough to warrant it; they're called "comments". ;-)

when explaining things to others, or working things out on paper, i use diagrams as much as possible - the simpler the better

Steven A. Lowe
+1  A: 

if question_on_stack_overflow == LOL:
     if question_on_stack_overflow == noob.question("how do i install jquery"):
          troll();
     endif
endif

no i dont use it ever

related questions