Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Trace function

From: coussement:c:js:mil:be at: 22-Jun-2001 9:30

> 1) (re)factoring, > 2) objects, > 3) probe > > 1) My favorite way to deal with debugging is to avoid it as > much as possible (yeah, right! ;-) by (re)factoring the > code into small, black-box pieces that can be recombined as > flexibly as possible. This includes the use of higher-order > functions such as MAP. > > In my experience, I'm much more likely to *need* debugging > tricks with long sprawling functions than with concise ones. > > 2) Of course, I can get in a hurry and mess up even the most > simple-looking functions. By wrapping a group of related > functions into an object, and using data-like members of that > object as scratch space, I can more easily perform a test and > then look at the after-effects (or even add snapshot members) > to see where I went off the rails. > > 3) When I keep my individual functions small and orthogonal, > I usually find that a small number of well-placed PROBEs > help me get a function working and tested with less effort. > > In a way, I'm glad that TRACE is so unwieldy! I've used other > languages/platforms that had big piles of inspectors, "live" > data displays, breakpoints, etc... While those things may be > hard to against in *some* situations (embedded software, > kernel, and device driver development, for example), I find > that in most programming situations in a reasonable high-level > language, they make it all too easy for me to get sloppy in > my design and coding, because I've got such industrial-strength > automated crutches to fall back on! > > -jn- >
[My experiences on that field are similar to those of Joel. - BTW I don't know *MAP* what does it means ?- I try to use the most modular code possible by the isolation of functionnalities into specific functions and objects, and to protect the global context by the use of a local one (aka 'context). I like to see my code as an assembly of *LEGO* blocks, being able to test each one individualy, and putting it together to achieve an higher fonctionnality. For tracing I mostly use '? which tell me a lot about used words:
>> help ?
USAGE: ? 'word DESCRIPTION: Prints information about words and values. ? is a function value. ARGUMENTS: word -- (Type: any-type)
>> a: 35
== 35
>> ? a
A is an integer of value: 35 I put then a visual remainder for finding it back with ease when I don't need it anymore: (in the script) ? a ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< I used to develop in PowerBuilder, which has a rather big debug env. I remember losing more time finding back how to use it efficiently and finding my vars back, then debugging my code :-( I definitely prefer the REBOL approach: keep simple things simple ;-)) CU, chr== ]