This code was developed as part of the Simon's Institute Summer School, 2018.
The overall goal of this code is to determine the ground state of the 2D Ising model, but the goal of the exercise is to practice the following:
- Pair Programming
- Two coders work on one workstation, i.e. physically passing a laptop back and forth.
- One writes the code while the other observes to check for correctness.
- Frequently collabarte about possible approaches/solutions.
- Roles switch frequently.
- Test Driven Development
- A software development strategy that relies on a short cycle:
- Create Test (which will initially fail and thus defines short term goals).
- Write code until the test can be passed.
- Refactor code, i.e. clean up whatever was done so the code looks nice again.
- An additional possible step is to add documentation (via Doxygen?) after refactoring.
- A software development strategy that relies on a short cycle:
- Version Control (via git/github)
- Continuous Integration (via travis-ci)
- Detailed discussion given below
- Documentation (via Doxygen)
- This was not covered in depth, but in essence, it allows programmers to write documentation within the comments of their code.
Travis provides the following definition of continuous integration: "Continuous Integration is the practice of merging in small code changes frequently - rather than merging in a large change at the end of a development cycle. The goal is to build healthier software by developing and testing in smaller increments. This is where Travis CI comes in." In essence, the primary functionality of Travis appears to be to:
- Clone your github repo into a virtual environment
- Builds and tests your code
- Tells you whether the builds passed or failed.
I'm sure that there is much more available here, but this seems to be the most important part.
Below is a brief set of instructions on how to do this. It seems fairly intuitive and took me only a few minutes to set up.
- Go to travis-ci.com
- Link Github account, all public repos should appear
- Select a repo to work with and toggle the slidebar next to it to activate.
- Click on the repo's name to get started
- Click "Read the Docs and Get Started" to really figure out what is going on, though I'll try to write a brief tutorial here
- Add a .travis.yml file to your repository to tell Travis CI what to do (as described in the Travis documentation), commit and push this to the github repo.
- Go to travis-ci.com again to check the build status and see if your code passed or failed.
- Additionally, when you look at commits in github, there will be a green checkmark next to those that passed the unittest and a red x next to those that failed.
To install Doxygen, do the following, which is explained in the documentation here (git clone https://github.com/doxygen/doxygen.git).
- Clone the repository using the following steps:
git clone https://github.com/doxygen/doxygen.git
cd doxygen
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make
make install
- Create a configuration file (each project should get its own configuration file)
doxygen -g
This will create a file called "Doxyfile" that, when opened, describes and contains all of the settings that will be used to create the documentation.
It appears that most of the entries can be left alone and this will produce a generically formatted documentation.
Alternatively, one could read through the configurations documentation (http://www.stack.nl/~dimitri/doxygen/manual/config.html)
or use the doxywizard, which is a GUI that creates configuration files.
I simply chose to change only the project name and description, while leaving all other entries as the default.
*PROJECT_NAME
*PROJECT_BRIEF
*OPTIMIZE_OUTPUT_JAVA, which helps optimize the output for python scripts (because python looks more like java than c/c++
- To generate the documentation, you can now run:
doxygen Doxyfile
After doing this, with the default values I had, two new directories were created ./html and ./latex, containing the documentation in HTML and LaTeX formats.
4. View your documentation by pointing your browser to ./html/index.html
To get the pdf of the documentation, navigate to the ./latex directory and type make pdf.
Now that the documnetation has been generated, it is mostly useless if your code was poorly commented as mine was,
so the next step will be to properly comment your code so that the doxygen documentation provides meaningful information.
Since I am working primarily in Python, I will provide the details on doing this in that language, though all the information is provided in the doxygen documentation (http://www.stack.nl/~dimitri/doxygen/manual/docblocks.html)
To start, a documentation block starts with a ##
For example, the doxygen documentation provides this generic python file:
## @package pyexample
# Documentation for this module.
#
# More details.
## Documentation for a function.
#
# More details.
def func():
pass
## Documentation for a class.
#
# More details.
class PyClass:
## The constructor.
def __init__(self):
self._memVar = 0;
## Documentation for a method.
# @param self The object pointer.
def PyMethod(self):
pass
## A class variable.
classVar = 0;
## @var _memVar
# a member variable