From flowchart to program - code design for the newcomer
We're all used to seeing little flow chart diagrams on instrtuction sheets and in books - telling us things like whether we should call the doctor for our sick child, or let him/her sweat it out. So - for newcomers to programming - flowcharts are a natural way of drawing out what the program needs to do. But how to translate such a diagram into a program?
Programs are written as a series of instructions within a file - line by line, and the two lins coming down the page as shown in my first diagram isn't possible - so the first stage is to redraw the flowchart into a single line, as I've done here on the right. The lines are all joining the same boxes, but those boxes have been moved above each other and there are some jumps around.
Then you can start to see the structure of your code. The decision boxes are going to be "if" statements, with an "else" before the second of the sets of boxes that we stacked in the second stage. And there you have your first program structure to hand.
Progressing on further ... if you have one of the vertical stacks jumping BACK to the decision box, you'll be looking at a loop (with a world like "while" replacing "if"), and if each of the boxes performs a substantial task, then you'll want to write the code for it really simply as a call to a function which you'll write - programming at a macro level, and you can then separately flowchart and "solve" each block in turn. You're headed - without even realising it - for a structured programming technique ... (written 2011-09-29)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articlesQ904 - Object Orientation and General technical topics - Analysing a Programming Task 
Flowchart to program - learning to program with Well House - (2012-10-14) 
Specification, Design, Implementation, Testing and Documentation - stages of a (Java) programming project - (2011-07-21) 
Perl from basics - (2011-06-20) 
Teaching examples in Perl - third and final part - (2010-06-27) 
Uploading an image, document or pdf via a browser (php) - (2010-04-10) 
Planning! - (2009-08-08) 
Well structured coding in Perl - (2008-10-24) 
Daisy the Cow and a Pint of Ginger Beer - (2008-10-21) 
Learning to program in Perl - (2008-04-11) 
Perl, PHP or Python? No - Perl AND PHP AND Python! - (2008-01-20) 
Perl and Shell coding standards / costs of an IT project - (2007-09-11) 
The Fag Packet Design Methodology - (2006-06-06)
Some other Articles
How can I do an FTP transfer in Python?Passing optional and named parameters to python methodsBusy weekend of contrasts.Hangers, luggage and possessionsFrom flowchart to program - code design for the newcomerFlying Colours!Catching the fishes first?On this day ... one PHP script with three usesAway to train - but still around by video for Melksham meetingsStepping stones - early coding, and writing re-usable code quickly
4106 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83 at 50 posts per page
This is a page archived from The Horse's Mouth at
the diary and writings of Graham Ellis.
Every attempt was made to provide current information at the time the
page was written, but things do move forward in our business - new software
releases, price changes, new techniques. Please check back via
our main site for current courses,
prices, versions, etc - any mention of a price in "The Horse's Mouth"
cannot be taken as an offer to supply at that price.
Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).