Table Data Gatway + Decorator and/or Composition for find
Posted: Fri Jul 14, 2006 2:21 am
Hi
Lets asume we have Table Data Gatway built ....with CRUD and everything on a db table.
From ther on we start by findByName() method..... findByDate() method etc.
Now, this starts too look fishy...because if you want to seach by name and date you will build a 3rd method findbByNameAndDate() which is wrong.
So I am thinking of making on Find interface or abstract class. And implement from there
Find_Date implements Find
Find_Name implements Find
and then just build some compose object or something
This gives flexibility because once build, you could search by any combination...just building right objects...... I think this has something with composition/decoration but not quite sure.
Maybe someone more experienced will like to clarify the idea and show the right way to do it
Lets asume we have Table Data Gatway built ....with CRUD and everything on a db table.
From ther on we start by findByName() method..... findByDate() method etc.
Now, this starts too look fishy...because if you want to seach by name and date you will build a 3rd method findbByNameAndDate() which is wrong.
So I am thinking of making on Find interface or abstract class. And implement from there
Find_Date implements Find
Find_Name implements Find
and then just build some compose object or something
Code: Select all
$table->find (new Find_Date('2006-03-03'), new Find_Name('Tom')) ;Maybe someone more experienced will like to clarify the idea and show the right way to do it