When writing code, few things are more exciting th...
# water-cooler
b
When writing code, few things are more exciting than finding a legitimate application for recursion. Discuss.
s
legitimately, my most common recursive scenario is site navigation, or nested categories
Since i often find the best way to store them in a database is with a id & parent_id association, so it is easier to access a specific node. The difficulty is that building breadcrumbs from the child up to the root can make it a bit more tedious. Thankfully for me, in postgres you can write a Recursive CTE to get the records back solely with a query 🙂
t
i last used recursion to remove the java stack traces from cf exception dumps, including on nested exceptions. There was definitely cursing involved. I'm still waiting for my first use-case for recursive CTEs.
s
That sounds like a pretty cool feature, removing some of the noise from the cf exceptions! Did you make that available anywhere? I’d be interested in playing around with it if so
t
I didn't, but I could. It was a gigantic pain in the ass because exceptions are immutable, and the tag context blocks are apparently derived from the stack traces, so taking out the stack trace, but keeping the tag context was a lot harder than it seemed like it should have been.
s
Yeah, i can imagine! If you do find time, it might be a cool addition to we could add to the https://github.com/elpete/whoops error viewer used in coldbox
m
Bit late, but I once wrote a recursive utility app that started at the webroot, walked all the directories and counted each different type of file for each dir, and for specific file types (js,css,cfm,cfc, etc) it counted lines of code as well. It gave nice grand totals all at the end too. Yeah, I had one of those managers once..