Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Learning to write good programs in C and C++ - separating out repeated code

From our "learning to program in C and C++ day" yesterday - that's how we started our working year in the training business in 2011. "Learning to" courses, where we take people through the basic coding principles and concepts and in the language they'll actually be using are both the hardest work to present, and the most rewarding to the tutor when (s)he sees the results, and I'm delighted we've added these extra days to the front of many of our courses, even though they require me to commit my bank holiday or Sunday to training a small group.

We started off with "Hello World". All programming courses seem to do that - and it's an excellent idea as it's the minimalist program which shows how a program is edited, compiled and run in the source language that's being taught in class. I then expand the "hello world" example to add multiple outputs, outputs from calculations, variables, and inputs too. Yesterday's example went one step further - adding in a conditional too, where King Arthur decided whether to pay in cash or to charge his Excalibur card. [source].

Repeated code should be put into a loop ... and code that's likely to be reused from multiple places in a program should be put into a named block called a function. And that's what I did in the second major example of the day - that's [here]. A further expansion splits the function(s) into a separate file [here], the main code (for this first program) remaining in a different file - [here], and with a separate header file of templates to tell the compiler and loader how the various components of source are related to each other / what parts of the compile will be satisfied later by the loader. Header file example [here].

Courses mentioned in this article - Learning to program in C++ and Learning to program in C. These courses run at our Melksham, Wiltshire training centre and are intended for delegates with little or no prior programming experience. We offer other courses for delegates with prior programming experience who wish to learn C or C++ - see [here].

(written 2011-01-04, updated 2011-01-08)

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

C201 - C and C based languages - C Language Fundamentals
  [888] Turning C from source to a running program - (2006-10-06)
  [1671] Compiling C programs with gcc - an overview - (2008-06-10)
  [2005] Variables and pointers and references - C and C++ - (2009-01-23)
  [2576] What does const mean? C and C++ - (2010-01-15)
  [2842] Staring a C course with Hello World - why? - (2010-06-30)
  [3234] Your program - you just provide the filling in the sandwich - (2011-04-08)
  [3278] Do I need to initialise variables - programming in C, C++, Perl, PHP, Python, Ruby or Java. - (2011-05-05)
  [3591] Integer types, and integer overflows, in C - (2012-01-25)
  [3917] BODMAS - the order a computer evaluates arithmetic expressions - (2012-11-09)
  [4555] Preprocessor directives in C and C++ - what they mean - (2015-10-27)
  [4566] C - why is slow to write and debug) but fast to run? - (2015-11-01)


Back to
TransWilts - some things to see and do
Previous and next
or
Horse's mouth home
Forward to
New year, new C Course
Some other Articles
C++ - putting the language elements together into a program
C++ objects - some short, single file demonstrations
When is a program complete?
New year, new C Course
Learning to write good programs in C and C++ - separating out repeated code
TransWilts - some things to see and do
Arrays of arrays - or 2D arrays. How to program tables.
Opportunities for Melksham - new businesses in the town
Are there newspapers on New Years Day? Do the shops open on Easter Sunday? Do trains run at Christmas?
Perl, Python, PHP, Lua, Linux, and more - and business hotel too. Menu for 2011
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., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/3120_Lea ... -code.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb