As my Clojure application is now getting quite complex, I was curious as to what "workflow" people are using for design, development, testing and debugging.
I'll get started with what I've found, so far, though I am definitely open to suggestion. There are a few parts I'm not quite satisfied with. I use Emacs+Slime in windows (I'd prefer a Mac if I could afford one) as my primary development environment. I start Emacs with a project- specific batch file that adds all the libraries I use to the CLASSPATH environment variable and then invokes Emacs, so all I have to do to add a new library to the project is to dump it in the "lib" folder in my project, and add a line in the bat file. For high-level design, I usually just spend time thinking about it and jot down my ideas in a physical notebook. When I have a decent idea of where I'm going, I start banging out code - usually I do my mid- and low-level design as I code. Typically I just do the first thing that comes to mind that will work, and then refactor wherever I see an opportunity for improvement. I find that this works better than trying to do more detailed planning up front - no matter how much time I spent, there was always some variable or use case that escaped me and I'd end up making significant changes anyway. It also really tends to keep code size to a minimum. I try to write each expression in the REPL, first, to make sure it works, though this is becoming less and less necessary as I get more confident with Clojure. Currently I am in an effort to put my existing code, except for the UI portions, under complete test coverage using the test-is library. To keep things clean, I am putting all the tests for each file in a separate file. This is actually my first experience with unit tests. The motivator for it is a problem I am still struggling with - my time spent debugging is increasing exponentially relative to the amount of code I have. Hopefully unit tests, in conjunction with writing smaller, more atomic functions will allow me to have more confidence in individual functions which will ease the debugging process. Debugging itself is probably my biggest headache, and I think it's really the only point where Clojure's lack of maturity presents a real problem. When I encounter unexpected results, I typically follow this pattern: 1. If there is a stack trace, inspect it to see if it tells me the problem (usually it doesn't - it really only helps for syntax errors) 2. Inspect the code to make sure its nothing obvious. 3. Use the REPL to construct a data structure like the one in question, and pass it to the function that seems to be the problem (This can be a real PITA with a more complex structure - in my case, more often than not, it's a zip of an xml file. 4. Decompose the data structure and function from step 3 into their component expressions and apply them, one by one, until I find one that doesn't work. 5. Loop back to step 3, only one function further down the call stack, until I find the problem. 6. If I'm desperate or the problem is heavily recursive and too complicated to use the procedure above, I add trace statements. I hate doing this, though, since it requires adding lots of ugly (do (println...) ...) blocks and juggling s-expressions. This can take hours even for an extremely simple bug, if it's buried deeply enough. I have tried using JSwat - in some cases it can be of help, but I can't get it to work smoothly and reliably. If just inspecting a variable helps to solve the problem, then it's a help, but I can't make it reliably step through and inspect at each step of the way. Sometimes, it also will refuse to hit a breakpoint, for no apparent reason. My dream debugger would be to pause execution on a certain line, be able to step through function calls, and have a REPL with all local vars available so I could explore the problem. But I'm pretty sure that doesn't exist. Anyway, that's my process, and my frustrations. How do you all do it? --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---