Chapter 7. Creating Classes and Objects

In the previous chapter you learned how to group statements that performed a specific job into functions and subroutines (at least, that was the plan). This broke the code into small pieces that were easy to understand, and it freed you from duplicating the same code everywhere your program needed the corresponding action to occur. Because functions and subroutines are reasonably self-contained units, it’s easy to copy them out of one program and paste them into another.

Or is it? If you wrote another program that used a deck of cards, which functions, subroutines, and data items from the shuffle program would you need to copy? The answer might be obvious now, when you’ve just finished writing the program, ...

Get Faster Smarter Beginning Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.