News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Giorgio Sironi's Blog:
The Repository pattern
November 03, 2009 @ 09:49:35

Giorgio Sironi has recently posted a look at one of the more popular design patterns - the Repository pattern. He talks about how it can be used for two things: to create a collection of objects and the reuse of queries and their results.

A common infrastructure problem of an object-oriented application is how to deal with persistence and retrieval of objects. The most common way to obtain references to entities (for example, instances of the User, Group and Post class of a domain) is through navigation from another entity. [...] A Repository implementation provides the illusion of having an in-memory collection available, where all the objects of a certain class are kept

He gives an example of a method that grabs user information and encapsulate the database access for it so that it's not required to hit it for every run through their unit tests. He shows how to set up the interface for a GroupRepository and how to implement it in the test.

0 comments voice your opinion now!
repository design pattern tutorial


blog comments powered by Disqus

Similar Posts

WebReference.com: Creating a Custom RSS Feed with PHP and MySQL

Zend Developer Zone: MySQLND, MySQL_UH and other goodies available to PHP programmers

Marcelo Gornstein's Blog: Advanced telephony applications with PHP and PAGI using call flow nodes

Chris Hartjes' Blog: Handling Multiple Environments In Your PHP Application

DZone.com: Development Setup for Neo4j and PHP: Part 2


Community Events

Don't see your event here?
Let us know!


interview symfony2 performance voicesoftheelephpant podcast laravel opinion version series extension framework release php7 library api introduction install conference community example

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework