[thelist] re: BBS style recursion How-To
rudy
Rudy_Limeback at maritimelife.ca
Fri Dec 1 11:55:58 CST 2000
BBS style recursion How-To
http://evolt.org/index.cfm?menu=8&cid=3962&catid=17
gorgeous article, steve
a *boatload* of good comments in your code
aside: the comments showed up in green, too -- kinda cool, it made it a
lot easier for me to disregard the actual php code, which was in a font
too small to read anyway... but the point is, i was just reading your
comments to get the gist of the programming approach
there is another school of thought on the idea of presenting recursive
data from a database, and that is to let the database do the recursion
there are several ways to do this, in fact oracle and sql/server have
specialized approaches to this
i've always just done the poor man's version using plain and simple sql --
it requires left outer joins and an assumption about how many levels down
you want to indent, but once the query starts returning rows, you don't
have to do anything more complicated than print them, the data arrives
"already fully recursed," to coin a phrase (with the exception that you
have to assume it only goes so many levels deep)
indentation is straightforward, and is accomplished for example in cold
fusion by
<cfoutput group=level1>#level1#
<cfoutput group=level2>#level2#
<cfoutput>#level3#
</cfoutput>
</cfoutput>
</cfoutput>
i'm not saying your approach is wrong, but the more complex you get in
terms of structures and recursion and looping and stuff on the web server
side, in your own programming code and using functions and stuff, the more
difficult it will be to make changes to it later
i personally would hate to come in months later and try to figure out how
to change the code that's sitting behind this --
If we didn't find a child, then we've gone as far down
this particular branch of categories as we can.
We need to keep our startup variables the same and
use our second function - step_up to either find
further results on the same level, or to take us
back up the category tree.
sorry, not to pick on you or anything, steve
especially after you've gone so far out of your way to document something
for the benefit of evolt and the web development community
so thanks again for the article, and for taking the time to share with
evolt
rudy.ca
p.s. i know left outer joins aren't everybody's cup of tea, so feel free
to write me offlist if anyone wants more info...
More information about the thelist
mailing list