Re: Reading Source Code
From: Chris Sonnack (Chris_at_Sonnack.com)
Date: 04/28/04
- Next message: Chris Sonnack: "Re: Simple Parser"
- Previous message: Chris Sonnack: "Re: Aspects of programming languages in common"
- In reply to: deech_99: "Re: Reading Source Code"
- Next in thread: deech_99: "Re: Reading Source Code"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 28 Apr 2004 10:02:03 -0500
deech_99 wrote:
> I agree that diving into code is probably the best way of getting
> to grips with the program and becoming a better software programmer.
Say rather, "one of many ways". Merely reading code can be frustating
and unhelpful, depending on the code.
> My fear was that I would get into a 'badly-written' program that
> would instill bad habits.
Unlikely to happen from a single program. More likely to happen
due to your own unchecked efforts. IMO, one of the better mechanisms
for growing as a programmer is peer review and code walk throughs.
> I have been warned by other programmers that good programs in the
> eyes of a user are not always good programs in terms of exemplifying
> good programming practices.
The two are not highly connected. Users view only the surface of
the program and its outward behavior. They have no knowledge of
its internals.
Consider that the *appearance* and outward behavior of an automobile
has little to do with exactly how it is constructed. (Or more
precisely, little to do with how WELL it was constructed.)
Where the two do meet is in handling problems and the unexpected.
Badly written programs are often not robust (or can be downright
flakey), and THIS the users definitely notice.
> Perhaps the best way is a two-pronged approach where
> 1) A 'classic' program (eg Tex or Linux ) is studied with
> the aid of a book
> 2) I fearlessly dive into a more recent program which I
> wish to extend.
3) Submit your code to the merciless review of the appropriate
programming or language group on USENET. Folks there will be
more than happy to pick it apart in great and gory detail. If
you can take the heat--develop a thick skin--you will learn a
LOT. (Even bystanding the review of the code of others can be
a humbling and educational experience!)
> On a broader scope I would like to know why the practice of reading
> real-world code is not more widespread. In all other crafts the
> formative years of the student are spent learning what has already
> been done- a jazz musician, for example, studies others solos, and
> a writer is constantly reading. Why is it that programmers do not
> study other's source code as diligently?
That's a very good point. Some thoughts.
For artists (such as musicians and writers), "prior art" is indeed
a valuable source of education. Some (musicians in particular)
have self-taught themselves almost solely from prior art.
It may be that, in engineering-type disciplines, this is not quite
as valuable (for reasons you touch on: wide variety of quality).
In these disciplines, Established Practice and Formal Education
are more valuable, because there tends to be less latitude in how
a thing is executed.
That is, in art, there really isn't a right or wrong way to do
something. In engineering, there are some definite wrong ways!
Programming, IMO, lies in both worlds. It's part engineering (with
definite right and wrong ways) and part art (or craft). I've always
thought Architecture was the closest analogous profession. There
are some definitely wrong ways to design and build a structure, but
there is also a strong element of creativity.
-- |_ CJSonnack <Chris@Sonnack.com> _____________| How's my programming? | |_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL | |_____________________________________________|_______________________|
- Next message: Chris Sonnack: "Re: Simple Parser"
- Previous message: Chris Sonnack: "Re: Aspects of programming languages in common"
- In reply to: deech_99: "Re: Reading Source Code"
- Next in thread: deech_99: "Re: Reading Source Code"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]