Chapter 4 Review:

• How does OOP differ from procedural programming? (See page 120.)

OOP is built around blocks/objects that become modular - allowing a buidling up of applications from separate components - each of which are likely abstracted from the other, and encapsulated on their own.

• What is a class? What is an object? What is an attribute (or property)? What is a method? (See page 121.)

A class is a combination of attributes and methods.

• What syntax do you use to create a class? To create an object? (See pages 121 and 124.)

To create a class you declare it using class <Classname> {} - then you'll add attributes (variables) and methods (functions). An object is created by invoking new instance of a Classname.

• How do you create class methods? How do you call object methods? (See pages 121 and 124.)

You create class methods via functions. You call these methods via $object->methodName().

• How do you create class attributes? How do you reference those attributes within the class? How do you reference those attributes using an object? (See pages 121, 124, and 127.)

You create attributes through variable declaration. The attributes are referenced within the class definition using the special $this-> syntax. When referencing as part of an object, you use $object->attributeName

• What is a constructor? How do you create one? When is a constructor called? (See page 133.)

A constructur sets up the defaults and mandatory first steps of a class. Special syntax of __construct() is used. It is called upon creation of a new instance.

• What is a destructor? How do you create one? When is a destructor called? (See page 136.)

A destructor handles what what happens when an object expires either through unsetting of the object or the end of a function containing a created object. Special syntax of __destruct() is used.

• What is UML? How do you represent a class in UML? (See page 140.)

UML is Universal Modeling Language. It describes a standarized means of marking up classes and their contents. It is a 3 1 col by 3 row block with the class name on the first line, the attributes in the second row, the methods in the third.

• What is phpDocumentor? What are the arguments for using it? (See page 143.)

phpDocumentor is a php-based tool for created php documention from a comment syntax convention. Since documentation is too often foregone, it becomes a tool for captuing and organizing comments in code for others who may need to read, debug, workon or become owners of your code.

• What is a docblock? (See page 144.)

A docblock is syntax'd as follows:

/**  

*  

* Short description  

*  

* Long description  

* Tags

*/

This syntax let's phpDocumentor parse the file for these and organize contents into meaningful documentation.

 

Toggle Sidebar