O'Reilly logo

Head First Programming by Paul Barry, David Griffiths

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Modular Programming: Keeping things straight

image with no caption

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. Let’s find out how in the pages that follow...

Head First Health Club is upgrading some systems

Head First Health Club has a new CEO, and he loves new technology. He was shocked when he saw how old the sales systems were.

image with no caption

A point-of-sale (POS) system is just a computer program that works like a cash register. The boss doesn’t want to replace all of the cash registers immediately. He wants to begin with a trial system in the coffee bar.

Note

It would be nice if the systems you produce were modular in design. You’ll get to that AFTER you’ve spent some time understanding what’s required.

Let’s see what the coffee bar POS needs to do.

The program needs to create a transaction file

The POS program will record credit card sales in a file called transactions.txt. At the end of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required