Forum > Other

anybody pseudo code?

(1/2) > >>

Weiss:
I remember from my days learning Octave, there was a suggestion to write a pseudo code first, prior to writing an actual program. Back then I gave it my half-arse go, but it was almost like its own unique skill writing a pseudo code. It was a lot easier to just code. So I never explored it further. Is there any kind of standard of writing it? Is it worth the effort?

Reason I am asking is that there are some complex tasks lately, and I have a hard time visualizing the flow. Kind of thinking of putting it on paper and work from there. I printed my code, and that helps to keep a mental picture, but not enough.

440bx:

--- Quote from: Weiss on May 20, 2023, 03:06:58 am ---It was a lot easier to just code.

--- End quote ---
It often is, particularly for an experienced programmer.


--- Quote from: Weiss on May 20, 2023, 03:06:58 am ---Is there any kind of standard of writing it?

--- End quote ---
Even though most pseudo-code that is found "out there" seems to follow a pattern, I am not aware of a standard (that doesn't mean there isn't one.)


--- Quote from: Weiss on May 20, 2023, 03:06:58 am ---Is it worth the effort?

--- End quote ---
In most cases, an experienced programmer can write "pseudo-code" using _real_ code (IOW, it's not really pseudo-code) but, when something is complicated enough that going directly for "close to working" real code proves difficult then writing pseudo-code is definitely worth it.

What I consider pseudo-code is an outline of the steps necessary to accomplish a task.  All steps are broken down (further outlined/indented) until I can effortlessly "see" the code required to implement each task/subtask (it may still be a fair amount of code but, as long as there are no tasks/subtasks I cannot see in code then, I'm done.)

I always outline the high level structure of the program in order to group functional pieces.  The program source files are made to be parallel to the outline. So far, I've never seen anyone else do that but, I've tested the method on other programmers (they weren't Pascal programmers) and have gotten very positive feedback about the programs that were structured that way.

Note: In the great majority of cases, I only do that for "real" programs.  IOW, most programs don't get this "luxurious" structure.

HTH.

alpine:

--- Quote from: Weiss on May 20, 2023, 03:06:58 am ---I remember from my days learning Octave, there was a suggestion to write a pseudo code first, prior to writing an actual program. Back then I gave it my half-arse go, but it was almost like its own unique skill writing a pseudo code. It was a lot easier to just code. So I never explored it further. Is there any kind of standard of writing it? Is it worth the effort?

Reason I am asking is that there are some complex tasks lately, and I have a hard time visualizing the flow. Kind of thinking of putting it on paper and work from there. I printed my code, and that helps to keep a mental picture, but not enough.

--- End quote ---
Assuming with the "visualizing the flow" you've meant the "program execution flow", IMO you wouldn't get a clearer picture when writing a pseudo-code. After all, the "flow" already exists, and you'll just get (almost) the same thing but on paper.
To me, pseudo-code is a design phase tool or something which can be used to communicate an algorithm in some language-neutral way.
When I'm attacking a complex problem I often make a skeleton program with mock-up subroutines and then gradually add details and continue to decompose in the same way down. All this with lots of comment lines explaining not only the purpose of each routine/block, but also how it works.

The 440bx is right - it depends on how experienced the programmer is and his judgement will he be able to handle it in a "cowboy way" or he'll need some aids to do it.

If you want to visualize things, take a look at some modelling language as UML for example.

marcov:

--- Quote from: 440bx on May 20, 2023, 03:31:16 am ---In most cases, an experienced programmer can write "pseudo-code" using _real_ code (IOW, it's not really pseudo-code) but, when something is complicated enough that going directly for "close to working" real code proves difficult then writing pseudo-code is definitely worth it.

--- End quote ---

Most pseudo code looks quite like Pascal anyway, remnants of its teaching past....

I don't write pseudo code any more for the stepwise refinement method (where you increasingly detail the pseudo code till it becomes real code), but I do occasionally use pseudo code in communication with external programmers or my  boss/client to get some confirmation of an algorithm before I fully implement it.

Handoko:

--- Quote from: Weiss on May 20, 2023, 03:06:58 am ---... there are some complex tasks lately ...

--- End quote ---

Pseudo code is good for learning/teaching newbies. For complex tasks I use divide and conquer algorithm. Usually I will try to solve the harder first, write it as a module as a single project. Then continue with the others. Finally I will get several modules (or units), so I can use them in the real project.

https://en.wikipedia.org/wiki/Divide-and-conquer_algorithm

Navigation

[0] Message Index

[#] Next page

Go to full version