Prev | Current Page 265 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

Corporate management structures, the
U.S. tax system, and our view of the plant and animal kingdoms are just a few examples
of the systems that rely heavily on hierarchical concepts. Because OOP is based
on the premise of allowing humans to closely model the properties and behaviors of
the real-world environment we??™re trying to implement in code, it makes sense to also
be able to represent these hierarchical relationships.
For example, suppose that your application calls for a class titled Employee, which
is intended to represent the characteristics and behaviors that one might expect from
an employee. Some class members that represent characteristics might include the
following:
??? name: The employee??™s name
??? age: The employee??™s age
??? salary: The employee??™s salary
??? yearsEmployed: The number of years the employee has been with the company
Some Employee class methods might include the following:
??? doWork: Perform some work-related task
??? eatLunch: Take a lunch break
??? takeVacation: Make the most of those valuable two weeks
These characteristics and behaviors would be relevant to all types of employees,
regardless of the employee??™s purpose or stature within the organization. Obviously,
though, there are also differences among employees; for example, the executive might
hold stock options and be able to pillage the company, while other employees are not
afforded such luxuries.


Pages:
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277