[Tutor] Planning a program with algorithm?
Andrei
project5 at redrival.net
Mon May 30 22:11:56 CEST 2005
> I'm learning python by reading 'Python Programming for the Absolute
> Beginner' by Michael Dawson.
> In the book it says it's recommended to plan a prog.
> with pseudocode.
>
> Can i just ignore it?
I don't think it's a bad technique, but there's different ways of writing
pseudocode. The benefit of pseudocode is that you can write and inspect an
algorithm quickly (quicker than in the programming language). Having 1 line of
code for 1 line of pseudocode is in that regard a pointless use of pseudocode.
Code:pseudocode ratios of 3:1, 5:1 or so are more reasonable in my opinion.
By the way, this is roughly equivalent to the ratio of code required to do
something in a lower-level language compared to doing the same thing in
Python, which is why Python is comparable to pseudocode from the POV of
low-level languages.
One approach you could consider is to write pseudocode, turn it into comments
and write the real code in between those. That way you get the benefits of
pseudocode (being able to spot algorithm errors at a higher level) as well as
properly commented code. Difficult portions then automatically get more
comments, while easier portions get fewer comments - just as it should be.
Yours,
Andrei
More information about the Tutor
mailing list