PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1

CHAPTER 13 ■ DATABASE PATTERNS



  • Data Mapper: Create specialist classes for mapping Domain Model objects to and
    from relational databases.

  • Identity Map: Keep track of all the objects in your system to prevent duplicate
    instantiations and unnecessary trips to the database.

  • Unit of Work: Automate the process by which objects are saved to the database,
    ensuring that only objects that have been changed are updated and only those
    that have been newly created are inserted.

  • Lazy Load: Defer object creation, and even database queries, until they are
    actually needed.

  • Domain Object Factory: Encapsulate object creation functionality.

  • Identity Object: Allow clients to construct query criteria without reference to the
    underlying database.

  • Query (Selection and Update) Factory: Encapsulate the logic for constructing SQL
    queries.

  • Domain Object Assembler: Construct a controller that manages the high-level
    process of data storage and retrieval.
    In the next chapter, we take a welcome break from code, and I’ll introduce some of the wider
    practices that can contribute to a successful project.

Free download pdf