Procedural Programming • Procedural programming: writing programs made of functions that perform specific tasks • Procedures typically operate on data items that are separate from the procedures • Data items commonly passed from one procedure to another • Focus: to create procedures that operate on the program’s data
Working With Instances • Instance attribute: belongs to a specific instance of a class • Created when a method uses the self parameter to create an attribute • If many instances of a class are created, each would have its own set of attributes
Finding the Classes in a Problem (cont’d.) 1. Get written description of the problem domain • May be written by you or by an expert • Should include any or all of the following: • Physical objects simulated by the program • The role played by a person • The result of a business event • Recordkeeping items
Finding the Classes in a Problem (cont’d.) 2. Identify all nouns in the description, each of which is a potential class • Should include noun phrases and pronouns • Some nouns may appear twice
Finding the Classes in a Problem (cont’d.) 3. Refine the list to include only classes that are relevant to the problem • Remove nouns that mean the same thing • Remove nouns that represent items that the program does not need to be concerned with • Remove nouns that represent objects, not classes • Remove nouns that represent simple values that can be assigned to a variable