LISP: Notes - looking at code
When you download someone else's code ... then what?
You will want to try to run it, but you will also
want to manually trace it.
How to trace Object-Oriented (and/or) functional code.
- Look/skip through the code for all the defs.
Specifically, defstruct, defun, defclass, etc.
These are defining the functions and data structures.
You will see when they are used in the following:
- Where does the code start?
- At a top-level function call (or in OO, where something has
been instantiated and started (example, an applet on a webpage, a main method, etc.))
- Once found the starting call, trace code from there to see
when any particular function (method) is called. Be aware of
parameters passed and returned.
For lab 2, since some of your labs will take a long time to
figure out, or get to run, you should keep a log of
what you have been doing. - What did you do?
- what worked?
- what didn't?
- how did you get it to work?
- what was there?
- what did you add?
All of these can be included in a write-up of what your lab 2 was
all about. If you find a problem where you think the scope is too
large, a possibility is to pick only a small portion of the problem,
or, as mentioned earlier, do design and analysis rather than implementation.
My advisor used to discuss "smaller portions" as so:
If the project is too large, one can either
- go at it horizontally
look at the whole problem but
only discuss the design aspects; take a cursory look at each aspect of the high level
- go at it vertically
rather than look at the whole problem, pick
out one aspect of the problem and work on it in depth. Code it, discuss
possibilities, discuss how it will fit into the whole, but without a
lot of details about the whole.