Skip to content

jonocode – a developer's blog

I moved! –>

With a query in its own function, you can write calling functions that:

a). Retrieve a collection for that type of query.

b). Retrieve one result for that type of query.

c). Extend that type of query with more conditions.

d). Pass the query to other objects that take a query as a parameter (eg. sfPager).

e). Distribute processing to the appropriate ORM classes.

For example, you have a database of classes and students.

If you need to get a classes’ students, you make a request to the classroom->getStudents() query function.

The classroom->getStudents() function adds its criteria (eg. = #), and then passes that criteria to the StudentTable->getStudents() query function.

In short, you reduce repetition.  You enhance maintainability.  Because each query has a single responsibility.

More info:


Tags: ,

%d bloggers like this: