Object Oriented PHP Flashcards
What’s an abstract class?
A way of providing concrete base functions as well as abstract functions that must be implemented by concrete child classes
$black =& $white
make $black an alias for $white
=&
assign as alias =&
Abstract classes vs. interfaces
Abstract classes may have implemented methods, interfaces have no implementation in themselves
Object interface
A list of function names that a class must define if the class implements that interface
Benefits of abstract class over interface if multiple inheritance not required
To later add base functionality within the abstract class
Abstract classes feature single inheritance
Child classes can extend only one class at a time.
Abstract classes cannot be instantiated in-themselves
no new AbstractClassName()
What’s the main advantage of an interface?
That it allows you to define a protocol to be implemented for an object to have some behavior.
Singleton pattern
Special class that generates one and only one object instance
Factory method pattern
Building an inheritance hierarchy of creator classes
Abstract factory pattern
Grouping the creation of functionally related products
Prototype pattern
Using clone to generate objects
What is PDO?
PDO offers an API that consolidates most of the functionality that was previously spread across the major database access extensions, i.e. MySQL, PostgreSQL, SQLite, MSSQL, etc. The interface exposes high-level objects for the programmer to work with database connections, queries and result sets, and low-level drivers perform communication and resource handling with the database server.
What are the two parts that make up PDO?
PDO consists of the extension itself which exposes the interface and a low-level database-specific driver.