[thelist] re: BBS style recursion How-To

Steve Cook sck at biljettpoolen.se
Mon Dec 4 02:22:47 CST 2000


Thanks for the comments Rudy. I certainly didn't think you were picking! I'm
glad it was a thought provoking article.

I agree with your principle that doing what you can in the database is the
way to go. When I first developed the code behind this example, I looked
into using database joins. After several mails to the list (this was about a
year or so ago) and searching around on the web, I didn't find anything that
approached what I wanted to do. If one has a system that goes to an unknown
depth of indentation, than recursion appears to be the best way to go.

Having said that, I'm fairly confident that there must be a database
solution. Perhaps having an extra column with "depth" information might
help? Maybe data shaping or some kind of deeper recursive programming within
the database could present ready-formed data? Either way, I thought through
these ideas and failed to find something that didn't create extra problems
when adding the data to the data store.

You're right about the difficulty of updating the recursive functions. I
will also certainly hate it when I have to come in and make adjustments a
year from now :-) What is so difficult with recursion is thinking through
all the possible conditions that exist. The best method I have found is to
create a small sample set of data that contains all the possible conditions
one will encounter in the real data - multiple branches from a single stem,
jumps from deep levels up to shallow levels - whatever you think you may
ancounter in your data. Then you need to trace your path through the data
and try to describe what needs to happen at every step. Once you've started
programming, using lines that print the status of all the variables you are
using in the functions helps to track what is going on inside your program.
It's by no means easy, or applicable to every situation, but it's an
incredibly powerful technique for when data is "well-formed" (i.e. follows
certain structural rules) but "boundless" (i.e. has unknown depth).

Regarding the formatting of the article, well I think that someone in the
evolt admin team should take the credit for that! I did a certain amount of
formatting (entity conversion, <CODE></CODE> tags and the like) but I was as
surprised as you about the nice clear green comments :-)

.steve


----------------------------------
   WapWarp - http://wapwarp.com
 Wap-Dev - http://www.wap-dev.net
 Cookstour - http://cookstour.org
----------------------------------




More information about the thelist mailing list