Jump to content
iyeager

Pseudocode

Recommended Posts

Any developers write (draw?) pseudocode before actually hacking out code?

I guess it's the part of me that doesn't want to ignore the text based education I've had, but I've written pseudocode for everything as it helps me think everything out prior to actually writing. However, I can't seem to do it in Labview and I was hoping perhaps some of you could shed some light on how you accomplish the "roughing" out process?

-Ian

Share this post


Link to post
Share on other sites

Hi Ian

Often I do a bit of pseudocode on a scrap piece of paper before I code something especially if it is a little nested or I want to talk it over with somebody else first. I am not sure I see your problem, after all the whole point of pseudocode is that it is NOT specific to the language you are going to code in.

for example

initialise power meter

initialise signal generator

get frequency list

for each frequency

set signal generator to frequency

get power reading from power meter

check stop button state

if STOP

STOP

plot graph

this can help you plan what you are going to do before you code it up and applies equally well for LabVIEW or C or Python

Danny

Share this post


Link to post
Share on other sites

Or just do that in the BD as your initial "sketch" of what you'll be actually coding and use your pseudocode as the comments...

Share this post


Link to post
Share on other sites

Depending on the complexity of the problem, I also start with pseudo-code. On the more detailed level, I keep an uml model together with the code. For state machines, at least a bubble and arrow diagram (using dia, OpenOffice/MSOffice, or simple a paper) will be my starting point. Both get pasted as pictures on the BD. The most 'primitive' form is a simple comment on the BD as Val pointed out.

I think this practice is 'good' and even is encouraged by NI for the exams (I think you get points when just commenting 'this vi will save the data' as much as coding it actually).

Those design comments also serve as documentation later.

Felix

Share this post


Link to post
Share on other sites

And can be pasted into the documentation area of VI Properties as a "summary" of what the entire VI is meant to accomplish...

Share this post


Link to post
Share on other sites

Pseudocode is too close to implementation for it to be much value to me. I'll do pseudocode in text languages when I'm trying to figure out how to implement an algorithm. In Labview I'm usually working at a higher level than specific algorithms. It's fine for single threaded apps, but I haven't had much luck modelling multi-threaded applications with it. Like Felix I'll sketch out state diagrams or flow chart-ish diagrams during design to clarify my thoughts.

Share this post


Link to post
Share on other sites

I have to agree with Daklu. I only start to use any kind of flow-charts/Pseudocode for very large programs. I usually define these when the program must be split up so that multiple developers can work simultaneously. On one project, I used the state chart module fairly effectively for a single developer.

Share this post


Link to post
Share on other sites

Any developers write (draw?) pseudocode before actually hacking out code?

I have a composition book of descriptions and flowcharts and (pseudo-) state diagrams and UML models and K-maps and ... well, you get the idea. It helps me think through to a good implementation of the system and writing it down ensures that I'll remember (or have a good reference) to what I was thinking a month ago before something interrupted me.

Tim

Share this post


Link to post
Share on other sites

a month ago before something interrupted me.

Wow... that's quite an interruption. :D

Share this post


Link to post
Share on other sites

Wow... that's quite an interruption. :D

Heh, yea, yet it is surprising how many times it's been that long especially when there are multiple projects going on at once.

Share this post


Link to post
Share on other sites
I have a composition book of descriptions and flowcharts and (pseudo-) state diagrams and UML models and K-maps and ... well, you get the idea. It helps me think through to a good implementation of the system and writing it down ensures that I'll remember (or have a good reference) to what I was thinking a month ago before something interrupted me.

Me too - I have an artist's sketch book, a 2B pencil and a good soft eraser :)

Share this post


Link to post
Share on other sites
Bar napkin flow charts :)

Ditto!

Does dreaming about while loops and event structures count? :P

Share this post


Link to post
Share on other sites

I do a lot of block diagram generation (using Dia or Visio) for larger/more complex programs. I find it helps me keep track of what needs to be done and what has been done. Also, I find it's a good way to communicate with others especially managers. They like the pretty colors. I fill completed elements with green.

Jason

Share this post


Link to post
Share on other sites

Does dreaming about while loops and event structures count? :P

Only if I can plead the fifth...

Share this post


Link to post
Share on other sites

Ditto!

Does dreaming about while loops and event structures count? :P

No. Dreamed of broken resistors. Didn't replace a schematic.

Wish you better dreams.

Felix

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.