> at the risk of sounding negative and (-; thus getting  
> "moderated" ;-) ... I'm very interested in taking another stab at  
> clojure after putting it down for a while, but I had real trouble  
> debugging my programs.  I'm looking for advice and/or an approach.

Aside from two areas — JVM problems, such as with gen-class'ed  
classes, and exceptions occurring in Java code — I've found that the  
best general approach is to build small, functional programs.

If every function is only a few lines long, and stands mostly alone,  
you can build from the bottom up and rely on your foundations. Test as  
you go, by hand or automatically — I find that automation is much less  
important with functional programming, because there are fewer knock- 
on effects of changes, but that's another kettle of fish — but if you  
keep most of your program free of side effects, composed of small  
functions, you should find that debugging in the large is greatly  
reduced.

No side effects mean that the only time you can have a bug is if you  
get the wrong output from your function for the inputs you provided;  
debugging in that case means inspecting your function, and maybe  
navigating outwards the tree of calls it makes to other pure  
functions. Add tracing until you find the function that's returning  
the wrong thing, and fix it.

If you're finding that you're managing a lot of state, and thus have  
trouble debugging, then you're probably not taking a sufficiently  
functional approach. (A big hint is if you find yourself wanting a  
stepping debugger to watch values change. It's the "change" part  
that's worrying!)

If that's not your problem, could you elaborate so that we might all  
opine? :)

-R
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to