Apps

Poll: How do you use pseudocode?

Do you pseudocode as a regular part of your development process, only for complicated scenarios, or not at all? Let us know by taking this poll.

In a recent discussion of local developers and technical recruiters, it came up that not many new developers understand things like writing pseudocode. I don't write pseudocode as often as I used to, but I do find that it is an invaluable tool for breaking through roadblocks in the development process.

Very few developers that I know seem to use pseudocode at all. Is pseudocode a major part of your development cycle?

J.Ja

About

Justin James is the Lead Architect for Conigent.

18 comments
Gabby22
Gabby22

As others have said above, I use a form of English pseudocode for specification (for others to design and code), documentation (to show complex decision paths) and as part of design in rare complex cases. In very special cases, I might invent a semi-formal notation as a form of shorthand to compact the design and description and make it easier to assimilate and review. Occasionally, I've had a module that consistently gives problems of one form or another, and which I've needed to redesign/refactor more than once. In these cases, I'll almost always use pseudocode to sort it out and keep the pseudocode as source documentation.

minstrelmike
minstrelmike

Most of my code is copied from some other code and then modified. But when I start something new, it starts as sorta pseudocode with lists of appropriately named functions or objects that get broken down more and more and then converted into real code. This is especially useful for me when doing a brand-new language or project from scratch.

jkiernan
jkiernan

I use it, mainly because the target language for the project may change. Syntax is just glorified formatting, after all.

ron
ron

In many years of developing embedded systems firmware, I typically did my detailed design in pseudocode. During the majority of that time, the target programming language was assembly language and when doing the implementation, I "played" the role of a compiler, converting my pseudocode into assembly language. Of course, in doing that it gave me another opportunity to address the logic of my pseudocode. I think people have gotten away from using pseudocode (or seemingly any other pre-implementation design) with the use of high-level languages. I think most of the high-level languages, e.g., , C++, C#, etc., are often used for simultaneous design and implementation, i.e., no distinct "design phase". However, as cryptic as some of the high-level language constructs are, I still think there is a benefit in using pseudocode in the design phase.

rwidegren
rwidegren

When you have to modify something that you wrote five years ago (or worse yet, something that someone else wrote) it's a lot easier to understand the flow of logic by looking at the pseudocode that the real code.

ian
ian

I use pseudocode when writing specs for other people to code. Very useful to help organise the logic flow, and it means I don't have to worry about getting the precise syntax of the target language correct, as I may not be an expert in using that language.

dogknees
dogknees

I tend to use it in the code editor to rough out the structure. So, it's more like standard code, but with a lot of the fiddly details left out. I use this to make sure my approach is going to work as intended. Then I'll often run it in the debugger to ensure the flow is as I expect it to be. Once I'm happy with that I gradually fill in the blanks with more detail. Often this will happen at a high level and then at the more detailed level in the more complex parts of my code. When brainstorming ideas I still write a lot of psuedo-code on paper. No matter how long I use computers, I still find it easier to "think on paper" than on the screen, whether coding, designing other things or whatever.

Tony Hopkinson
Tony Hopkinson

where i'm thinking through the steps, or for QA, when I'm describing what the code does so they can come up with test scenarios. I never put it in the code though, that's just asking for it. Essentially I'm trying to avoid various implementation considerations. Use a dictionary, or a sorted list, create a helper class, can I get away with a struct etc. So a list of the databases on the system, could be a straight List of strings Or a Dictionary of structs keyed by name... psuedo code is more what than how for me. It's never why.

Slayer_
Slayer_

I often just write the basic loop/if/switch blocks with nothing in them and just quick descriptions describing them. I usually only do this to help give instructions to another programmer without doing all the work for them. If app version less than 15 then index marker + 5 else choose by app version version 16 index marker + 9 version 17 index marker +15 version 18 index marker -9 version > 18 messagebox "You are doing the impossible, quit cheating!" end end

mattohare
mattohare

I write statements closer to natural language that describe what should happen. It takes more of the form of a title of the section of code. Most of these remain as headers to help the self-documenting nature of the code. It resembles the outline format for speeches that I learnt in my high school and university days.

Sterling chip Camden
Sterling chip Camden

My design sketches are usually just rough drafts in the programming language I intend to use. I might completely scrap it before I write the real thing, or I might just edit and refine it. IMO, to be an effective programmer in any given language means that you need to be able to think in that language. If you have to translate your thoughts from English, then you've added another filter that you probably don't need.

apotheon
apotheon

This is especially relevant when using particularly high-level languages, which tend to look somewhat like pseudocode, anyway. I do a lot of my coding in Ruby these days, which has an elegant enough syntax that writing "pseudocode" that conforms to the expectations of the language I'll use to write the code basically ends up being a case of "programming by wishful thinking", where I write valid Ruby code that just happens to contain classes and methods that I need to define to make it work.

jcmusic
jcmusic

Any translation should be fairly easy and automatic. What is more important to good design IMO is the underlying concept being implemented. A specific language is a derived from the base concept, yes? I prefer English because you can make qualitative "why" statements to indicate intent, hand it off to someone else, and have it clearly understood, rather than implied. The concepts that you implement should support the intent. Of course the two (english vs code) will mix at times.

Jaqui
Jaqui

thinking in the language you are programming in is a huge help, but in a truly complex project using native language pseudocode as an early step to lay out the logic can really help reduce rewrites of the actual code. you can see where there is a lot of reused logic, making it easier to put code into place that can be used across different parts of the project. and working in your own native language to plan the project's code layout is generally faster.

apotheon
apotheon

If there is a significant difference in programming paradigm between your pseudocode assumptions and your programming language of choice, writing it in pseudocode first is bound to do almost nothing but waste a lot of time. Traditional pseudocode does not map well to Prolog at all, for instance. I guess you're probably okay if you write all your code in Pascal, though.

Tony Hopkinson
Tony Hopkinson

far though. The step between list of thingies you need to iterate through forwards and backwards, to do this with a double linked list is short and very slippery.