Skip to content

Commit 1b4bc2c

Browse files
committed
Better phrasing, biohazard easter egg
1 parent 41c0e12 commit 1b4bc2c

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

chapters/Coding_style.tex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ \chapter{Coding style}
4646
Don't worry about the overhead of calling a function.
4747
If you use optimization flags like \texttt{-O3}, the compiler will try to inline them anyway.
4848
\item\textbf{Modules}---Separate your program into logical units.
49-
Combine related functions and subroutines into modules\footnote{It's also convenient to put all physical parameters (number of particles, $\pi$, $c$, $k_B$, etc.) into their own module, even if they're just constant numbers. You can then ``load'' the parameters into your subroutines with the \keyword{use} statement instead of having absurdly long lists of arguments, or worse, global variables.}.
49+
Combine related functions and subroutines into modules\footnote{You may also find it convenient to put all physical parameters (number of particles, $\pi$, $c$, $k_B$, etc.) into their own module, even if they're just constant numbers. You can then ``load'' the parameters into your subroutines with the \keyword{use} statement instead of having absurdly long lists of arguments, or worse, \Biohazard\ global variables \Biohazard.\index{global variables|see {biohazard}}\index{biohazard}}.
5050
For example, a single module with function integrators, or ODE solvers.
5151
If you use the object-oriented features of Fortran, it is also good practice to create separate modules for classes, \eg, a sparse-matrix object.
5252
\item\textbf{Comments}---Comments are kind of a double-edged sword.
53-
If used wrongly, they can actually hurt readability.
54-
The golden rule is: never explain \emph{how} it works, just \emph{what} it does.
53+
If used improperly or left unmaintained, they actually hurt readability.
54+
The general idea is to avoid explaining \emph{how} your code works and instead just mention \emph{what} it does.
5555
The how should be evident from the code itself.
56-
\emph{``Good code is its own best documentation.''} If you follow the other guidelines regarding naming and keeping functions small, you can generally suffice with a small comment at the beginning of every function or subroutine.
56+
\emph{``Good code is its own best documentation.''} If you follow the other guidelines regarding naming and keeping functions small, you can generally suffice with nothing more than a small comment at the beginning of every function or subroutine.
5757
\end{itemize}
5858
One final point, not of style, but important nonetheless: start every program and module with \keyword{implicit none}\marginnote{The \texttt{-fimplicit-none}\index{compiler flags!-fimplicit-none} compiler flag will also turn off implicit typing globally.}\index{Fortran!implicit none@\keyword{implicit none}}.
5959
This is an unfortunate holdover from older versions of Fortran; it forces you to explicitly declare all variables, instead of allowing Fortran to infer the type from the name.

coding_notes.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
\usepackage{epstopdf}
1111
\usepackage{listings}
1212
\usepackage{makeidx}
13+
\usepackage{marvosym}
1314
\usepackage{microtype}
1415
\usepackage{nag}
1516
\usepackage[all]{nowidow}

0 commit comments

Comments
 (0)