How can I handle multiple views of a data object? Which design pattern is acceptable?
Posted
by
tranquil.byte
on Stack Overflow
See other posts from Stack Overflow
or by tranquil.byte
Published on 2010-12-21T17:51:10Z
Indexed on
2010/12/21
17:54 UTC
Read the original article
Hit count: 255
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.
© Stack Overflow or respective owner