02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 3 ■ OBJECT-ORIENTED PROGRAMMING<br />

While this code isn’t necessarily bad, there’s a lot to keep in mind while coding. The array of the<br />

affected person’s attributes must be passed <strong>and</strong> returned from each function call, which leaves margin<br />

for error.<br />

To clean up this example, it would be desirable to leave as few things up to the developer as<br />

possible. Only absolutely essential information for the current operation should need to be passed to the<br />

functions.<br />

This is where OOP steps in <strong>and</strong> helps you clean things up.<br />

The OOP Approach<br />

Here’s the OOP approach to our example:<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!