MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Fw: Finding errors in my code?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg48270] Fw: Finding errors in my code?
  • From: schmitther at t-online.de (Hermann Schmitt)
  • Date: Thu, 20 May 2004 04:03:47 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com


 Hello,
 your proposals are good, but they do not help in the case, that you forget
 semicolons in functions or closing brackets.
 In this cases error messages, which specifiy the location of the error,
 could be very useful.
 Hermann Schmitt


 ----- Original Message -----
> From: "Murray Eisenberg" <murray at math.umass.edu>
To: mathgroup at smc.vnet.net
> To: <mathgroup at smc.vnet.net>
> Sent: Wednesday, May 19, 2004 8:42 AM
> Subject: [mg48270] [mg48243] Re: [mg48218] RE: [mg48060] Re: [mg48057] Finding
errors
> in my code?
>
>
> > [This is a reply to the original poster.]
> >
> > Another technique, not exlcusive of inserting Print statements into a
> > (presumably long and complicated) function definition, is to "debug
> > before writing the program", that is:
> >
> > 1. Do it step-by-step first, without defining any function, evaluating
> > each little expression in turn to that it works (with various kinds of
> > values for the intended input variables).
> >
> > 2. Encapsulate each of the steps, or perhaps groups of the steps, into a
> > "little" function and test those functions.
> >
> > Only then combine things into the final program.
> >
> > An often welcome result of this approach, aside from making debugging
> > easy, is you find the final program consists merely of some combination
> > of the "little" functions; or that some of those "little" functions are
> > themselves of more general use than originally intended.
> >
> > This approach is hardly unique to Mathematica and works nicely, in fact,
> > with any interpreted programming language.  (For a compiled language
> > it works, too, but with considerably more difficulty, since you
> > typically have to write program stubs and special-purpose covering
> > functions, etc., to get it to work.)
> >
> > David Park wrote:
> > > We might hope for something better, but I always find that the
quickest
> way
> > > to debug is to add a Print statement to the code at a judicious point
> giving
> > > the values of various state variables. I find this much easier than
> using
> > > Trace. The warning and error messages are only a rough guide anyway
and
> > > don't necessarily tell you where the error originates.
> >
> > --
> > Murray Eisenberg                     murray at math.umass.edu
> > Mathematics & Statistics Dept.
> > Lederle Graduate Research Tower      phone 413 549-1020 (H)
> > University of Massachusetts                413 545-2859 (W)
> > 710 North Pleasant Street            fax   413 545-1801
> > Amherst, MA 01003-9305
> >
> >
> >
>


  • Prev by Date: RE: Extracting Coefficients and Powers
  • Next by Date: Re: Extracting Coefficients and Powers
  • Previous by thread: Re: RE: Re: Finding errors in my code?
  • Next by thread: Eliminate duplicates using Union [] in a