DRY way to insert source code into an article?

"Daniel Wellman" <wellman-pD6z9c7pN/[email protected]>
Newsgroups gmane.comp.programming.language-of-the-year
Message-ID <[email protected]>
Hi all,

I'm starting to write articles about programming and I'd like to
include source code snippets into my article.  My strategy was to get
the source code examples working, then annotate sections of code which
should be imported into the body of the article.  The goal here was to
avoid copy-paste problems of putting incorrect or stale source code
examples into the document.

How do other pragmatists approach this problem?  

In my case, the source code will be Java, and I'm open to picking a
tool for the prose part of the article -- ultimately the final output
format will be whatever the publisher can accept (I'm working on
finding out that part).  Do people write the article in some plain
text format (TeX?  DocBook?) or some open document format (ODT?) and
then use a template-generation strategy to generate final document?

Thanks for your advice,
Dan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.