Zend PHP 5.3 Certification Exam
Object Oriented Programming
Functions and Arrays
Data Format & Types
Strings and Patterns
Databases and SQL
Web Features 1
Which of the following OOPS design patterns is used to encapsulate a data source so that accessing data source components becomes hidden within the class that implements the pattern?
Answer option C is correct.
ActiveRecord is used to encapsulate a data source so that accessing data source components becomes hidden within the class that implements the pattern. The ActiveRecord pattern is an approach to accessing data in a database. A database table or view is wrapped into a class; thus, an object instance is tied to a single row in the table. After creation of an object, a new row is added to the table on saving it. Any object loaded gets its information from the database; when an object is updated, the corresponding row in the table is also updated. The wrapper class implements accessor methods or properties for each column in the table or view. The ActiveRecord pattern is used to encapsulate the data source so that accessing the data source components becomes hidden within the class that implements the pattern.
Answer option D is incorrect. The Model-view-controller (MVC) pattern separates the business logic (Model) from the display logic (View) and the decisional controls. In MVC, the user initiates an action by calling the Controller. After that, interfaces with the Model causes the Model to perform some actions and changes its state. Finally, the View is called for refreshing the user interface to reflect the changes in the Model and in the requested actions of the Controller.
Answer option A is incorrect. In the Registry pattern, a user can add data (both values and objects), and retrieve them as required from other parts of an application. Since a single Registry object handles all such data, it makes passing data and objects around an application far more simple than passing all such values as individual parameters to a constructor or setup method.
Answer option B is incorrect. The factory pattern is an object-oriented design pattern. Like other creational patterns, it deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The factory method design pattern handles this problem by defining a separate method for creating the objects whose subclasses can then override to specify the derived type of product that will be created.
© 2013 Zend PHP Certification Exam