PDA

View Full Version : Does anyone here actually use pseudocode?



swoll1980
July 19th, 2009, 05:02 AM
Or is it as useless as it seems. I'm doing my homework, and I have to write these programs in Python, pseudocode, and flowchart them. It would seem to me, that the flowchart does everything the pseudocode would do (as far as a cross platform translation goes.) . Isn't this just over kill, or do people actually use this stuff?

OutOfReach
July 19th, 2009, 05:13 AM
I usually use Python as my pseudocode. It might not be the best practice but it works for me.

days_of_ruin
July 19th, 2009, 05:14 AM
Or is it as useless as it seems. I'm doing my homework, and I have to write these programs in Python, pseudocode, and flowchart them. It would seem to me, that the flowchart does everything the pseudocode would do (as far as a cross platform translation goes.) . Isn't this just over kill, or do people actually use this stuff?

Python, pseudocode, what's the difference?:P

NovaAesa
July 19th, 2009, 05:25 AM
I quite often write out my algorithms in pseudocode on paper before actually coding them. It makes things much easier when you actually go to code the algorithm in the language of choice.

Not so sure I would be keen on flow diagrams though... I had to do them in highschool for software design & dev, and didn't really see how they helped.

swoll1980
July 19th, 2009, 05:38 AM
Not so sure I would be keen on flow diagrams though... I had to do them in highschool for software design & dev, and didn't really see how they helped.

I guess it depends on the person. I look at the flowchart, and that makes things easier for me when it comes time to code it.

gtr32
July 19th, 2009, 05:38 AM
Isn't this just over kill, or do people actually use this stuff?

Since it's homework, don't worry if it is overkill, just do it. :)

School work, you always wonder, "am I ever even going to use this", but many things you end up using without even realizing you did. As for pseudo code, most likely you will end up using it.

Especially places like Ubuntu forums, when you post something on the codes section, unless it's language specific topic, you would rather post it in pseudo than python. Everyone knows how to read pseudo syntax. You could draw a flow chart and attach it to your post but in most cases I'd prefer pseudo. :)

Incense
July 19th, 2009, 06:19 AM
I had to use it when I took programing classes. It drove me nuts! I would just rather write real code. I'm a flowchart guy myself. But you have to do what your teacher wants right?

RiceMonster
July 19th, 2009, 07:46 AM
pseudocode and flowcharts **** me off because that's not the way I work. I had to make them in my first programming class, but I always just wrote the code first. Honestly, it's way too often that I get it wrong on my first planning, so I'd have to go back and fix the psuedocode after I wrote the code, so it makes a lot more sense to me to just start writing the code.

lisati
July 19th, 2009, 07:58 AM
The nearest thing to pseudocode I've used in recent years looks more like a broad outline in English of what needs to happen, occasionally sprinkled with something like "result <-- total of doohickey list".

tridentblack
July 19th, 2009, 08:02 AM
The nearest thing to pseudocode I've used in recent years looks more like a broad outline in English of what needs to happen, occasionally sprinkled with something like "result <-- total of doohickey list".

That's exactly how it SHOULD be done in my opinion. We all know we are supposed to comment our code to death. Why not just sketch out the plan of what you're going to do before doing it, and leave it in as comments? To be honest I don't know how I'd program without that.

gtr32
July 19th, 2009, 08:54 AM
pseudocode and flowcharts **** me off because that's not the way I work. I had to make them in my first programming class, but I always just wrote the code first.

I guess the big question is, do you do the design first and then code, or vice versa?


it makes a lot more sense to me to just start writing the code

I think that answered the question. :)

gtr32
July 19th, 2009, 08:58 AM
That's exactly how it SHOULD be done in my opinion.

You can leave out "in my opinion"...

stwschool
July 19th, 2009, 09:02 AM
I guess I'm kinda weird. I probably break all the rules of good practice here but then in my defence I can build a 200k php script (not all in one file!!) and know exactly which line a problem's occurred on, and build fully relational databases without ever having to design them on paper. Once you've done it a while, certain things just become instinct and you don't bother writing plans out because it's there in your head pretty much instantly. Its served me well over the years, producing some really cool projects, never once being hacked (while my asp-loving colleagues got hacked repeatedly) and always getting higher pay than everyone else as I could do stuff they couldn't. Sometimes it pays to break the rules.

PartisanEntity
July 19th, 2009, 11:27 AM
Well pseudocode and a flow chart achieve the same thing. They are meant to give you an outline of the end result and are meant to help highlight processes and their order.

So I can see how flowcharts or pseudocode can be seen as redunted if you have to do both.

I am not a flow chart person, so I prefer to use pseudocode before programming.

In my case, planning does save me a lot of work later, so whether I am programming or doing web development, I scribble everything on paper first.

Barrucadu
July 19th, 2009, 11:32 AM
I find both rather confusing, especially flowcharts. I prefer to just dive straight in to the code.

Blacklightbulb
July 19th, 2009, 12:00 PM
When I program I never plan anything beforehand. What is done in pseudocode I keep in my memory. But damn when it comes to documentation.

GeneralZod
July 19th, 2009, 12:04 PM
I find that the older I get, the less I write down on paper beforehand. I'm not sure if this is advancement or regression :)

I'll sometimes jot down pseudocode for novel algorithms, but have never drawn up a flowchart as far as I can remember.

PartisanEntity
July 19th, 2009, 12:20 PM
I find that the older I get, the less I write down on paper beforehand. I'm not sure if this is advancement or regression :)

Definitely advancement I would say :). I only started learning to program about 1 year ago, if I don't plan things and jot them down on paper to get an overview of what I want to do I will end up wasting a lot of time re-writing badly formed code.

koleoptero
July 19th, 2009, 12:22 PM
When we were told in some exams to write some programs in any laguage we wanted but preferably using pseudocode, so that they could check the algorithms easier, I wrote them in C# just to **** them.

But I have used pseudocode to teach some friends about algorithms.

ddrichardson
July 19th, 2009, 12:33 PM
I use pseudocode (leaning more to plain English) but definately not flowcharts. They're a means to an end but pretty much useless outside an individual object's methods.

I suspect the reason they're taught is progression, if you teach flowchart->pseudocode->code then the student is happier with the concept of UML->coding.

Be greatful COBOL is all but dead, at Uni we had to do DFD (http://en.wikipedia.org/wiki/Data_flow_diagram) and PFD (http://en.wikipedia.org/wiki/Process_flow_diagram) for everything. There was software to make it neat but only a wide plotter could output them tidily.

Bodsda
July 19th, 2009, 01:08 PM
I think I have used psuedocode once. But it was pointlessly boring. I felt like I was sort of writing some sort of code that sort of did absolutely nothing.

My philosophy has always been to code it bit by bit, adding prompt print statements after conditionals so I can see how the flow is actually working. Then clean up when it works.

Flow charts are just a diagramtical way of imagining the flow of your program. If writing it down helps, then fine, but I find it easier to think of that stuff in my head. I get confused when I write it down.

swoll1980
July 19th, 2009, 02:40 PM
Alot of the the pseudocode gets confusing to read, and write, especially nested "if" statements. They look like rats' nest.

Mr. Picklesworth
July 19th, 2009, 04:13 PM
That's exactly how it SHOULD be done in my opinion. We all know we are supposed to comment our code to death. Why not just sketch out the plan of what you're going to do before doing it, and leave it in as comments? To be honest I don't know how I'd program without that.

That's how I do it. I create my classes, lay out comments to describe how they will behave. It actually works better than pseudocode, because the process still helps me see where things can be streamlined, where they are redundant and where flaws will appear.

Pseudocode and flowcharts are fine and dandy for sharing ideas, which I guess is why the class has them. Personally, though, I just stare blankly at most flowcharts and comment on whether they look pretty, then ask for the proper English documentation. Maybe some people are so used to the things that they actually serve a purpose.

Shpongle
July 19th, 2009, 04:18 PM
i hate having to do it , it does help but i prefer to code it first

wojox
July 19th, 2009, 04:38 PM
I never liked psuedocode, if you understand conditional statements and loops and function and function calls then it seems a waste. Flow charts are cool to understand Algorithms.

betrunkenaffe
July 19th, 2009, 04:55 PM
I don't use either. If I'm doing a project that requires me to figure out the logic, I'm usually looking at breaking it down to as small of problems as possible. I then write down what each section should be doing and how they interact. Then I make it happen.

JohnnySage50307
July 19th, 2009, 05:04 PM
To communicate an algorithm to someone else, I typically use pseudocode. This is pretty useful whenever you're teaching someone else and want them to do a little work for themselves.

Ordinarily in robotics applications, we also use a combination of pseudocode and flowcharts, along with other graphical representations of the system to help model whatever we're trying to design. This is important because the algorithm itself should be independant of the language (if it's properly designed) and anyone with a mastering of some language should be able to replicate whatever algorithm you are modeling.

gtr32
July 19th, 2009, 05:06 PM
I don't use either. If I'm doing a project that requires me to figure out the logic, I'm usually looking at breaking it down to as small of problems as possible. I then write down what each section should be doing and how they interact. Then I make it happen.

That makes me want to ask...how do you feel about UML?

To the OP, where is UML in your teachers agenda? Soon to follow?

I am curious also, how many of the posters here do software for a living?

jomiolto
July 19th, 2009, 05:06 PM
If it was a choice between pseudocode and flowcharts, I'd pick pseudocode almost everytime. I'm just not a visual person and pseudocode is easier for me to understand than flowcharts.

I typically use pseudocode only when I'm planning some non-trivial algorithms (especially when I need to keep track of invariants). But most of the time I just plan the data structures and modules used in the program and then the code comes quite "easily" from that.

Also, it seems that the older I get, the more time I spend with pen and paper. When I was young(er), I used to go straight to coding after getting an idea and I'd spend a day coding something, then a couple of days debugging it to make it work (kind of). These days I spend a day designing and thinking, another for coding and some more thinking and then I find out I don't need to do much debugging at all.

MikeTheC
July 19th, 2009, 05:09 PM
on Swoll1980_Asks_A_Question
do input_routine
assign result of input_routine to var The_Question
evaluate The_Question
if The_Question > "" then
pass The_Question to "Mr. Picklesworth"
end if
end evaluate
end assign
end Swoll1980_Asks_A_Question

Mr. Picklesworth
July 19th, 2009, 05:29 PM
Another thing to keep in mind is that, if your application is designed awesomely enough (eg: without any hacks and with clearly named functions), it should feel just like pseudocode anyway. Then all you have to do is write the Python program, remove the syntax and you have pseudo pseudocode.

Bodsda
July 19th, 2009, 05:34 PM
on Swoll1980_Asks_A_Question
do input_routine
assign result of input_routine to var The_Question
evaluate The_Question
if The_Question > "" then
pass The_Question to "Mr. Picklesworth"
end if
end evaluate
end assign
end Swoll1980_Asks_A_Question

I fail to see how that psuedocode is quicker to write down then coding



swoll1980_is_happy_with_answer = 0
question = "Do you use psuedocode?"
while swoll1980_is_happy_with_answer == 0:
answer = forum_input("Answer the question: ")
swoll1980_is_happy_with_answer = raw_input("Enter 0 for no or anything else for yes: ")

print "Answer is: %s" % answer

gtr32
July 19th, 2009, 05:47 PM
I fail to see how that psuedocode is quicker to write down then coding

Maybe because that pseudocode goes into too much detail? Your code does not match that pseudocode BTW, pseudo for your code would be something like this:

ask "Do you use pseudocode?"
loop while answer is yes
print answer

MikeTheC
July 19th, 2009, 06:16 PM
I fail to see how that psuedocode is quicker to write down then coding

Well, see, I've never even heard of pseudocode before.

HermanAB
July 19th, 2009, 06:34 PM
Hmm, my first attempt at anything never works, so that is my pseudo code...

Bodsda
July 19th, 2009, 06:46 PM
Maybe because that pseudocode goes into too much detail? Your code does not match that pseudocode BTW, pseudo for your code would be something like this:

ask "Do you use pseudocode?"
loop while answer is yes
print answer

Your right, it is not the same as his psuedocode, but it does more in less lines. That is of course because he includes an end line for everything but still.

gtr32
July 19th, 2009, 06:51 PM
Your right, it is not the same as his psuedocode, but it does more in less lines. That is of course because he includes an end line for everything but still.

True. I think he could have done it in one or two lines.

ask a question
if question is not empty pass the question to "Mr. Picklesworth"

swoll1980
July 20th, 2009, 12:24 AM
To the OP, where is UML in your teachers agenda? Soon to follow?



I don't know. We haven't covered it yet. I don't even know what it is.

lisati
July 20th, 2009, 12:37 AM
I see pseudocode as something that lies somewhere in between my native language (English) and real code. As such, it's one of a number of tools, along with flow charts, structure diagrams, and other things of a similar nature, that are intended to make it easier to produce quality code that gets the job done.

forrestcupp
July 20th, 2009, 01:54 AM
To communicate an algorithm to someone else, I typically use pseudocode. This is pretty useful whenever you're teaching someone else and want them to do a little work for themselves.

That is actually the only good use I can think of for pseudocode.

Other than that, in my opinion, pseudocode is a waste of time, and time is money.

It's definitely productive to think ahead of time about your goals and ways to implement them. But why waste your time writing out detailed pseudocode that isn't compilable, then having to rewrite everything in real code?

You need to learn to think in whatever programming language you're using. I use C++ for everything, so I think in C++. I don't want to slow myself down thinking in fake code.

And who really figures out an entire program before they start coding? I like to program in sections, getting things compilable different parts at a time. That way, I can see my progress.

But like others said, if it's homework, just do what they tell you. Then when you're on your own, you can do it however you want.

gtr32
July 20th, 2009, 02:19 AM
And who really figures out an entire program before they start coding?

It depends on what extend we're talking about, and also of the environment. I know of quite a few projects that were completely modeled out before single line of code was written. I don't know if we're talking about different things here but a good software model in many cases saves a lot of time and grief, and like you said, time is money.

Lets say you're in a plane on your way to meet a customer, and you have pen and paper in front of you, or even a laptop. You are thinking of a piece of software you need to write, are you going to do it in C++ or will do pseudocode? For preliminary drafts, I'd pick pseudo or diagram majority of the times. Sometimes pseudo is better suited (for me) for the problem, and sometimes it's diagram.

Compucore
July 20th, 2009, 02:30 AM
Flowcharts are kind of useful I use to do it when I was taking programing in the early 90's on a vax vms. It is suppose to give you an overall look of what the application or program is suppose to do. And the pseudocode is more or less the detailing of what goes where with formula and scripts. I found that pseudocoding went through too many revisions for me to give a count at any given time. Thank god for word processors to keep track of what went where when writing it out on that. This is a proper way of doing it and commenting the source code with what each function or proceedure depending on the language being used. Delphi/Pascal still have proceedures and functions in them. C++/C are strictly function types whe coding in them. ANd of course what variables are being used for within the application or program so anyone would take a look afterwards would know what the cariable do in a given function or proceedure.

When I do programming over here on the occassion I still do a little bit of flowcharting and mainly pseudocode. But I am heavy on the comments and variable. So that way there is no confucion afterwards.

COmpucore.

hobo14
July 20th, 2009, 04:25 AM
Python, pseudocode, what's the difference?:P
:P


I use peudocode whenever I'm writing something that only needs to be understood by a human, rather than a compiler.

It's just code without any particular syntax that can be understood by someone reading it, after all.

Pogeymanz
July 20th, 2009, 06:25 AM
I like pseudo code much better than a flowchart. My actual process is rather ridiculous, though.

I jump right into the code, realize within an hour or so that I'm in over my head. Then I write some pseudo code to collect my thoughts and I'll keep referring back to it as I do the rest of the code.

But I'm also a terrible programmer, so my method probably has no value.

lisati
July 20th, 2009, 06:30 AM
And who really figures out an entire program before they start coding?
One job I had it was department policy to have the programmer properly document a program and walk through it with someone else.
.

JohnnySage50307
July 20th, 2009, 06:44 AM
One job I had it was department policy to have the programmer properly document a program and walk through it with someone else.
.

Most of my homework assignments required that we provided a pseudocode solution a week before handin. On top of that, all IEEE Computer Science Society(CSS) and Robotics & Automation Society(RAS) articles must provide documentation of an algorithm in a language-independant manner, therefore pseudocode is a must on both the professional and academic levels.

betrunkenaffe
July 20th, 2009, 07:05 AM
That makes me want to ask...how do you feel about UML?

To the OP, where is UML in your teachers agenda? Soon to follow?

I am curious also, how many of the posters here do software for a living?


Been a while now, from what I remember, I liked it because it was a simple way of setting it up. I didn't have to mess around with too much structure (or at least not logical structure which completely translates to code).

joebodo
July 20th, 2009, 11:08 AM
I tend to use pseudo code when explaining something to other programmers. I use flow charts for explaining things to the business people. Both have their purposes.

Learn UML - it helps in job interviews. :D

forrestcupp
July 20th, 2009, 03:35 PM
It depends on what extend we're talking about, and also of the environment. I know of quite a few projects that were completely modeled out before single line of code was written. I don't know if we're talking about different things here but a good software model in many cases saves a lot of time and grief, and like you said, time is money.I am definitely a believer in figuring out your goals and getting ideas for implementation ahead of time. So I guess I can go along with the flow chart thing; I'm just not that neat about it. My flow chart consists of scribbled notes of all the different variables I'm going to need and ideas for some of the tasks that will need to be performed.

I'm talking about taking it to the extent of actually writing out detailed pseudocode for everything that is going to happen in a project before you even start writing real code. To me, that's a real waste of time. Planning is good; writing detailed fake code for everything and then having to rewrite it all in real code is bad.


One job I had it was department policy to have the programmer properly document a program and walk through it with someone else.
.
By documenting, do you mean commenting your code, or do you mean writing it all out in pseudocode first? Commenting should be required in any job. But if you're talking about pseudocode, that's a pain.

Dullstar
July 23rd, 2009, 06:35 AM
I think you could mainly get by with only Python. And I thought my brother had excessive homework.

anroy
July 23rd, 2009, 06:41 AM
There are sometimes details that are hard to express in a flowchart.

So I do type out that kind of logic in a casual pseudo-code that is a combination of C and just plain English. I don't overly concern myself with having tons of rules or being consistent about them, just so long as the logic is understandable to me and my clients.

rkirk
July 23rd, 2009, 10:08 AM
Like a lot of people, apparently, my pseudocode is basically python, though I might slip in some C-style syntax accidentally out of force-of-habit (such as declaring variable types or using brackets to group blocks of code). Of course, I hardly even do this all that often; I usually just start writing what I want until I decide it's good enough (projects are never finished... only abandoned, as they say).