From d2a9dfcad9bbfe1fa7fc981a49b266477ee785d5 Mon Sep 17 00:00:00 2001
From: Blaise Thompson <blaise@untzag.com>
Date: Sat, 7 Apr 2018 20:08:50 -0500
Subject: 2018-04-07 20:08

---
 software/chapter.tex | 52 ++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 42 insertions(+), 10 deletions(-)

(limited to 'software/chapter.tex')

diff --git a/software/chapter.tex b/software/chapter.tex
index 59dd4a9..26636f1 100644
--- a/software/chapter.tex
+++ b/software/chapter.tex
@@ -46,8 +46,13 @@ comes down to software development:  %
 	\item On average, scientists spend approximately 30\% of their work time developing scientific
     software.
 \end{ditemize}
-PrabhuPrakash2011a---35\% developing, breakdown by type of work...
-% TODO: finish this paragraph
+\textcite{PrabhuPrakash2011a} had similar results in their 2011 survey, finding that 35\% of
+research time is spent in programming and developing software.
+Most of that time (57\%) is spent \emph{``finding and fixing errors in their programs''}.  %
+The amount of software work done for each scientific project is very heterogeneous, with projects
+ranging between 5\% and 95\% software development time.  %
+To me, the averages reported by \textcite{HannayJoErskine2009a} and \textcite{PrabhuPrakash2011a}
+seem roughly correct for the average Wright Group member.  %
 
 Despite the importance of software to science and scientists, most scientists are not familiar with
 basic software engineering concepts.  %
@@ -94,9 +99,8 @@ are following today---indeed sometimes it is easier to follow best practices.  %
 In the United States, funding agencies have recognized the crucial role that software plays in
 science.  %
 The National Science Foundation has a long-running ``Software Infrastructure for Sustained
-Innovation'' (SI$^2$) program, which endeavors to take a \emph{``leadership role in providing software as
-enabling infrastructure for science and engineering research''} [CITE https://www.nsf.gov/pubs/2012/nsf12113/nsf12113.pdf].
-% https://www.nsf.gov/funding/pgm_summ.jsp?pims_id=503489
+Innovation'' (SI$^2$) program, which endeavors to take a \emph{``leadership role in providing software as enabling infrastructure for science and engineering research''}. \cite{SI2}  %
+Other funding agencies have similar projects.  %
 
 \section{Challenges in scientific software development}  % ========================================
 
@@ -221,8 +225,8 @@ This is indispensable when trying to diagnose software problems.  %
 In order to use version control as effectively as possible, try to save the package after every
 change (feature addition, bugfix, etc).  %
 Typically version control is coupled with uploading to a remote server, for example using git with
-GitHub \cite{GitHub}, GitLab [CITE] or git.chem.wisc.edu \cite{git.chem.wisc.edu}, but version
-control need not be synonymous with uploading and distribution.  %
+GitHub \cite{GitHub}, GitLab \cite{GitLab} or git.chem.wisc.edu \cite{git.chem.wisc.edu}, but
+version control need not be synonymous with uploading and distribution.  %
 Tools like git have a lot of fantastic features beyond simply saving [CITE], but those are beyond the
 scope of these ``good enough'' recommendations.  %
 Also consider defining a version for the software package as a whole.  %
@@ -292,7 +296,7 @@ This section will discuss OOP in the context of a Python implementation.  %
 The basic idea of OOP is defining object types (classes) that are self-contained.  %
 These classes define pieces of associated data (attributes) and associated procedures (functions)
 within themselves.  %
-Once the class is defined, instances of that class are created.  %
+Once the class is defined, instances of that class can be created.  %
 Instances, as the name implies, are just specific ``concrete occurances'' of a given class.  %
 The classic example: \python{Dog} is a class, \python{fido}, \python{spot}, and \python{duke} are
 three dogs---three instances of the dog class.  %
@@ -300,7 +304,7 @@ three dogs---three instances of the dog class.  %
 OOP is easier to demonstrate than explain, so let's have some fun with some working Python
 examples.  %
 First, we will define a class.  %
-\begin{codefragment}{python}
+\begin{codefragment}{python, label=sof:lst:person}
 class Person():
 
     def __init__(self, name, favorite_food=None, hated_food=None):
@@ -344,8 +348,36 @@ The child class, then, can benefit from all of the behaviors enabled by its pare
 maintaining its own identity where needed.
 The inheritance pattern makes it very easy to cleanly define expectations and shared structure
 throughout a large piece of software without repeating functionality.  %
+As an example, let's create a child of or \python{Person} class, defined in
+\autoref{sof:lst:person}:  %
+\begin{codefragment}{python}
+class GradStudent(Person):
 
-% TODO: more exposition on inheritance, perhaps including an example
+    def react_to(self, food):
+        if food == self.hated_food:
+            return 'thanks!'
+        else:
+            return super().react_to(food)
+\end{codefragment}
+Again, let's make an instance and see how it behaves:
+\begin{codefragment}{python}
+>>> joe = GradStudent(name='Joe', favorite_food='pizza', hated_food='falafel')
+>>> joe.react_to('falafel')
+'thanks!'
+>>> joe.react_to('pizza')
+'yum! my favorite'
+\end{codefragment}
+\python{joe} has the same preferences as \python{mary}, but we were able to \emph{overload} the
+behavior of \python{Person} to give \python{joe} a different reaction when faced with his
+\python{hated_food} (the joke being that graduate students will eat anything).  %
+The wonderful thing is that all of the other behaviors---the \python{__init__} method, the reaction
+to \python{favorite_food}---were inherited from \python{Person}.  %
+We could even add new functionality to our \python{Person} class, and that functionality would
+immediately be available to \python{GradStudent}.  %
+In complex programs with trees of inheritance being able to edit one class to change the behavior
+of entire sections of the software is a very useful capability.  %
+You can even have inheritance between different packages, allowing programmers to customize or
+extend the behavior of existing tools for their specific needs.  %
 
 OOP is a deep subject with many patterns and concepts behind it.  %
 There are many places to read further [CITES].  % BJT: KFS can you give me some citations?
-- 
cgit v1.2.3

