Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Format Code in Research Reports [closed]

I am currently writing a formal research report, and I'll be including code with this report.

Question: Is there an accepted way of displaying code in research reports? I'm thinking both in terms of font, spacing, et cetera, and whether the code should be displayed inside the document, or in an appendix.

The code will be JavaScript and PHP. None of the sections of code will be more than 25 lines (so they're mere snippets). There will be approximately half a dozen snippets. Each of the snippets will have a couple of paragraphs explaining what is happening in the code, and a discussion on its pros/cons.

I have no contact with the body to whom the report will be submitted to, and they have no published guidelines on how to format code (please do not question these points).

like image 213
GlenCrawford Avatar asked Mar 18 '10 06:03

GlenCrawford


1 Answers

This is my preference:

When writing inline, get rid of code that is irrelevant to the explanation (such as import statements as previously mentioned, but potentially also variable declarations that are "obvious" and the like). The goal of code placed inline should be for easy crossreference with the paragraph describing that code block.

Code placed in appendices should be complete (as in - you can put this into your compiler and press go).

Don't be scared of placing heavily cut down code in snippets, along with a reference to the appendix containing the full code - the appendix code is for someone to read/run separately. the inline code is for people to glance at and help understand the specific point of that section.

like image 62
Ben Clifford Avatar answered Sep 23 '22 15:09

Ben Clifford