A common workflow for me when prototyping something, and then I let it grow into a fullblown program, with org goes something like this:
* Main
This program will print out "Hello, world!".
#+NAME: main
#+BEGIN_SRC c :tangle hello.c :noweb yes
<<includes>>
int main(void) {
<<main-body>>
}
#+END_SRC
* Includes
- stdio :: this is included to get =printf=
- others :: if I had other includes I'd explain why here
#+NAME: includes
#+BEGIN_SRC c
#include <stdio.h>
#+END_SRC
* Main body
Maybe an explanation of the algorithm
#+NAME: main-body
#+BEGIN_SRC c
printf("Hello, world!\n");
#+END_SRC
Literate programming doesn't care about the order, I can put that main at the bottom or in the middle. This allows me to introduce program concepts in a logical fashion that is different from what the compiler wants or needs. This allows me to, for instance, group all data structures and even share code across them where this would be less feasible in straight C. References like the `<<main-body>>` can be shared by multiple code blocks.Obviously, as programmers, we want to minimize repetition. But sometimes a language forces us to repeat ourselves. If it gives us a way to include common source blocks, that's awesome (like you can make a header file called common.h that every one of your source files includes). But that's feasible in every language. Nor are the macro systems ideal in every case where it is technically feasible.
As I write the code, usually in one pane of tmux, I'll tangle it. Then in a separate pane (usually on the right) I'll execute the code. Or I may have something that monitors the files for changes and builds it automatically and runs tests.
EDIT: This is also an effective technique for developing an understanding of a new code base. Bring all the code into one big source block in a new org file (or whatever you use). Tangle it and make sure it's the same as the original (this process gets repeated a lot, make it a script).
Grab segments of the code and extract them into new blocks (with a properly named reference). I usually do this with large chunks (whole class declarations, struct declarations, or function definitions).
Document what the code does and its relation to other segments. Repeatedly extract segments until they're down to reasonable chunks (a 500 line function? It's probably worth going down to 10-50 smaller blocks covering each logical section).