Separation question?
Posted: Tue Mar 28, 2006 10:22 am
I have this simple class, that reads a hierarchical structure of elements from a database into an array and sorts it.
Now I would like to present that hierarchi in an HTML-list, but after reading a lot of posts in here, I've come to the conclusion, that it's best to separate the rendering part from the datahandling part (am I right?)...
It sounds so easy in theory, but how do I do this separation in practice?
I can't use a method in my class to render the HTML - that wouldn't be separation I think.
I can't make a simple foreach-loop in my HTML "template", cause it isn't that simple to make the list from the array (I have to use a recursive function).
My questions are:
1. Where should I put the code for rendering the list?
2. Should I make another class for that?
3. or should I just write the rendering code directly in the HTML?
4. or maybe something completely different?
Hope some of you can help me find a clean solution.
/Asger
Now I would like to present that hierarchi in an HTML-list, but after reading a lot of posts in here, I've come to the conclusion, that it's best to separate the rendering part from the datahandling part (am I right?)...
It sounds so easy in theory, but how do I do this separation in practice?
I can't use a method in my class to render the HTML - that wouldn't be separation I think.
I can't make a simple foreach-loop in my HTML "template", cause it isn't that simple to make the list from the array (I have to use a recursive function).
My questions are:
1. Where should I put the code for rendering the list?
2. Should I make another class for that?
3. or should I just write the rendering code directly in the HTML?
4. or maybe something completely different?
Hope some of you can help me find a clean solution.
/Asger