How can I handle multiple views of a data object? Which design pattern is acceptable?
- by tranquil.byte
I have a person object.
class Person {
private $name;
...
}
I need to be able to change how they are displayed on the front-end ( visitors have control ). They can choose list view, grid view, photo view for example.
class PersonDisplay {
public function displayList() {
// Query database
// Output html to display in list mode
}
public function displayPhoto() {
// Query database
// Output html to display in photo mode
}
}
Is this an acceptable way to handle the presentation of the items on the front-end or is there a specific design pattern I should be researching to help me with this task? Does anyone have any suggestions or ideas where this could go wrong or if this could potentially make maintenance a nightmare?
The Person object was just an example very similiar to what I am using.