5

有没有人在大型 Java 项目中使用过noweb literate 编程工具,其中必须在不同的子目录中生成多个源代码文件?你是如何用 noweb 管理这个的?是否有任何资源和/或最佳实践?

4

2 回答 2

5

Noweb 将转储相对于当前工作目录或您指定的绝对路径的文件。只是不要在文件名的末尾使用 * (以避免插入 # 预处理器指令)。我建议使用 %def 和 @ 来显示您定义和使用名称的位置。

<</path/to/file.java>>=
  reallyImportantVariable += 1;
@ %def reallyImportantVariable

noweb 让您重新排序和(真正的胜利)重用代码片段,我认为 javac 不会理解。

我同意,因为大多数人都希望您会使用 javadoc,所以您可能正在逆流而上使用 noweb。

于 2009-04-21T23:10:58.883 回答
3

Literate Programming works its best if the generated intermediate code can point back to the original source file to allow debugging, and analyzing compiler errors. This usually means pre processor support, which Java doesn't support.

Additionally Literate Programming is really not necessary for Java, as the original need for a strict sequential order - which was what prompted Knuth to write a tool to put snippets together in the appropriate sequence - is not present. The final benefit of literate programming, namely being able to write prose about the code, is also available as Javadoc which allow you to put everything in as comments.

To me, there is no benefit in literate programming for Java, and only troubles (just imagine getting IDE support).

Any particular reason you are considering it?

于 2009-01-11T18:04:02.380 回答