so, everyone is in general agreement that...
> Separating layout, logic & data is a virtue in any programming
> situation [which is why HTML is such an abomination, but I digress].
I guess I should have clarified that that is what I believe in already
(the separating part, not necessarily the HTML as an abomination part).
My question targeted the messy situation where display itself depends a
lot on the data and requires logic. Hence, I chose the calendar example.
sub makeCalendar (typeOfCalendar, sizeOfCalendar, date) {
blah
}
typeOfCalendar could be any of month, week, year
sizeOfCalendar could be any of small, medium, large
date is, well... date
now, I can't really use a template in the "form letters" kind of sense.
I mean, take month... months can have 28, 29, 30 or 31 days, they would
be put in a table 7 across but sometimes 4, sometimes 5 rows. Year is
even more fun, especially if it is of the run on kind (not the silly 12
small months, but each month as a single row, 12 rows in the year
kind... fun figuring out the number of columns in that table.
anyway, the problem itself is not as important as the type of problem...
there are many occasions in which the display is determined by the data
received and maybe certain other conditions. At those times should I
bung the data inside the sub so it spits out a preformatted chunk of
displayable code, or should I get the raw data out of the sub and then
apply the logic. Reading the responses, I gather the former approach
would be better in such situations. I also learned that instead of
putting a bunch of print statements, I should make a variable out of the
display code, and then return the display variable.
That is a good summary, no?
Much gratitude for your combined patience. I have miles to go before I
sleep.
pk/