Page 16 -
P. 16
table of contents
modular programming
6 Keeping things straight
The code that you write will make its way into many programs.
And, although sharing is good, you need to be careful. One programmer might take
your code and use it in an unexpected way, while another might change it without even
letting you know. You might want to use one function in all your programs and, over
time, that function’s code might change to suit your needs. Smart programmers take
advantage of modular programming techniques to keep their workload manageable.
Head First Health Club is upgrading some systems 178
The program needs to create a transaction file 179
Use strings to format strings 180
The Format String Exposed 186
A late night email ruins your day 187
$50,000... for a donut?! 188
Only the sales from your program were rejected 189
The new bank uses a new format 190
Your coffee bar program still uses the old format 191
Don’t just update your copy 192
So how do you create a module...? 193
The transaction file is working great, too 199
The health club has a new requirement 200
The Starbuzz code 205
The two discount functions have the same name 206
Fully Qualified Names (FQNs) prevent your programs from getting confused 207
The discounts get the customers flooding in 213
Your Programming Toolbox 214
xv