Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
Python and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Lua, etc
 
Learning to program sample program - past its prime, but still useful

On a "Learning to Program in xxxx" day, we start off from basics and develop (first) a very simple input - calculate - output program then (second) we extend it to include conditional code and repeated code.

During the course of the day, delegates will ask "what about xxxx" and "could it do yyyy", and the example's expanded to show that. It's also expanded to illustrate the background behind the language and how certain things work.

The final result is a fabulously useful example for delegates ... and something that looks a bit past its prime for the outside reader - rather like a straggly dead flower. However, there is still some benefit in such an example, especially for pulling back during future courses for me to highlight one feature or another - so [here] from yesterday is such an example in C.

So what would I do if I was to 'refactor' this program?
• I would move to one statement per line (take out the illustration of how statements can be split between lines and put several per line
• I would move away from so many compile time constants and make values that would probably vary in the future into variables (a config file, perhaps)
• I would change the messages into something more prosaic and less fun
• I would turn the capacity into an integer variable
• I would turn type into a string
• I would remove the "program completed" message which is printed in the middle of the program (it now shows how conditional code ends with everything coming back together.
• I would add some sort of counter on my final loop to see how many times I had been round it - the user is probably going to want to know how many trains he needs to take his soccer crowd without counting output lines
and I would certainly improve commenting!

All of our public programming courses start with an optional "learning to program in xxx" day, for delegates new to programming, or who are rusty, or who feel that formal teaching will help them. Delegates who have strong prior programming expereince in anothe language can join us instead from the second morning onwards, when we do a fast start / revision to bring the whole class together. Not only does that get the experienced newcomers running quickly without the need to sit though a slower day, but it also ensures that newcomers get a repeated thorough introduction to the vital fundamentals, and in two slighly different ways to help enforce that most critical element of the language - the basics!

Upcoming public courses - [here]. If you have a group looking to learn to program in C, C++, Java, Lua, PHP, Ruby, Perl, Python or Tcl, please ask about private courses too. Writing in early December - I'm running a public course this week, and then I have 2 weeks of private courses in the run up to Christmas. But we're open for 2015 bookings and they'll be honoured at 2014 prices if you book by 31st December.

(written 2014-12-02)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
C203 - C and C based languages - Conditionals and Loops
  [4323] Learning to program - Loop statements such as while - (2014-11-22)
  [4322] Learning to Program - the conditional statement (if) - (2014-11-21)
  [3397] Does a for loop evaluate its end condition once, or on every iteration? - (2011-08-18)
  [3384] Loops - a comparison of goto, while and for - (2011-08-10)
  [3243] Breaking the running sequence - an introduction to conditional statements and loops - (2011-04-11)
  [3200] How a for loop works Java, Perl and other languages - (2011-03-12)
  [3121] New year, new C Course - (2011-01-05)
  [3004] Increment operators for counting - Perl, PHP, C and others - (2010-10-18)
  [2570] Function Prototypes in C - (2010-01-11)
  [2002] New C Examples - pointers, realloc, structs and more - (2009-01-20)
  [1696] Saying NOT in Perl, PHP, Python, Lua ... - (2008-07-04)
  [1582] Ruby, C, Java and more - getting out of loops - (2008-03-19)
  [1220] for loop - how it works (Perl, PHP, Java, C, etc) - (2007-06-06)
  [1191] Smart English Output - via PHP and Perl ? : operator - (2007-05-18)
  [962] Breaking a loop - Ruby and other languages - (2006-12-03)
  [353] Wimbledon Neck - (2005-06-20)

Q100 - Object Orientation and General technical topics - Learning to Progam
  [4575] Learning not just what a program does, but how to design it in the first place. - (2015-11-06)
  [4326] Learning to program - comments, documentation and test code - (2014-11-22)
  [4325] Learning to program - what are algorithms and design patterns? - (2014-11-22)
  [4324] Learning to program - variables and constants - (2014-11-22)
  [4318] Learning to Program - how we start to teach you at Well House Consultants - (2014-11-16)
  [4008] Reading and checking user inputs - first lessons - Ruby - (2013-02-17)
  [3895] Flowchart to program - learning to program with Well House - (2012-10-14)
  [3551] Some terms used in programming (Biased towards Python) - (2011-12-12)
  [3120] Learning to write good programs in C and C++ - separating out repeated code - (2011-01-04)
  [2973] Learning to program - where to start if you have never programmed before - (2010-09-28)
  [2898] Programming Standards from the start! - (2010-08-02)
  [2505] I almost put the bins out this morning - (2009-11-16)
  [2504] Learning to program in ... - (2009-11-15)
  [2326] Learn a new programming language this summer. - (2009-08-06)
  [2294] Can you learn to program in 4 days? - (2009-07-16)
  [2286] New to programming? It is natural (but needless) for you to be nervous - (2009-07-14)
  [2092] Tracking difficult bugs, the programmer / customer relationship - (2009-03-20)
  [2048] Learning to program in PHP, Python, Java or Lua ... - (2009-02-19)
  [2001] I have not programmed before, and need to learn - (2009-01-19)
  [1985] Learning to program as a part of your job - (2009-01-10)
  [1963] Best source to learn Java (or Perl or PHP or Python) - (2008-12-28)
  [1605] Learning and understanding scripting programming techniques - (2008-04-08)
  [116] The next generation of programmer - (2004-11-13)

C202 - C and C based languages - A first practical program
  [4632] Remember to ask the question before you listen for the answer - (2016-01-26)
  [3590] Defining, declaring and initialising variables in C - (2012-01-24)
  [3236] C - a first program that does something useful for you - (2011-04-09)
  [2580] C course inspires new teaching examples - (2010-01-16)
  [888] Turning C from source to a running program - (2006-10-06)


Back to
Test Driven Development - a first example of principle in C
Previous and next
or
Horse's mouth home
Forward to
Passing arrays into functions in C
Some other Articles
Segmentation Fault, Segmentation Violation, Bus Error, Stack Smashing
Command line and file handling in C
Simple C structs - building up to full, dynamic example
Passing arrays into functions in C
Learning to program sample program - past its prime, but still useful
Test Driven Development - a first example of principle in C
Flexible public courses - residential or commuting, programming newcomer or experienced, C or C++
Splitting out code into name blocks for clarity and reusability
Misty Melksham Morning
First Java Application - calculating the weight of a tablecloth
4759 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, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - 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).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2019: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/4337_Lea ... seful.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat