4.2. Developing an Object-Oriented Script

Object-oriented scripts require a lot of planning. You need to plan your objects and their properties and what they can do. Your objects need to cover all their responsibilities without encroaching on the responsibilities of other objects. For complicated projects, you might have to do some model building and testing before you can feel reasonably confident that your project plan includes all the objects it needs.

Developing object-oriented scripts includes the following procedures, which the next sections cover in more detail:

  1. Choose the objects.

  2. Choose the properties and methods for each object

  3. Create the object and put it to work.

4.2.1. Choosing objects

Your first task is to develop the list of objects needed for your programming project. If you're working alone and your project is small, the objects might be obvious. However, if you're working on a large, complex project, selecting the list of objects can be more difficult. For example, if your project is developing the software that manages all the tasks in a bank, your list of possible objects is large: account, teller, money, checkbook, wastebasket, guard, vault, alarm system, customer, loan, interest, and so on. But, do you need all those objects? What is your script going to do with the wastebasket in the front lobby? Or the guard? Well, perhaps your script needs to schedule shifts for the guards.

When you're planning object-oriented programs, the best strategy for identifying ...

Get PHP & MySQL® Web Development All-in-One Desk Reference for Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.