Skip to main content
Software development for researchers

Styles of development

This handout is tied to the following lecture

7. Styles of development
Table of contents

Development Styles

There are many different styles of development, e.g.

Although, for us scientists I believe really only a select few are relevant, which are also the ones covered in the lecture.

A few brief explanations of relevant styles can be found in the videos below since the articles above can be quite long and wordy.

TheAgileBroadcast - Is agile incremental or iterative?

ProDeveloper - Software Development Methodologies Introduction

Geoffrey Hubona - Chapter 2.2 Waterfall, Parallel, and V-model Approaches

Eye on Tech - What is the Agile Manifesto? An Introduction

Project management tools

Homework

A calculator

Write a general purpose calculator that can parse any single line calculation with *, +, -, and /. If it is too easy to do just int, also try to support float or even complex.

Develop this calculator using Test-driven development - write all the tests before you do a single line on the actual calculator.

Use the following test template

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
import unittest
import my_calculator

class TestCalc(unittest.TestCase):
    def test_add(self):
        self.assertEqual(my_calculator.run("1 + 1"), 2)

    def test_sub(self):
        self.assertEqual(my_calculator.run("1 - 1"), 0)

if __name__ == "__main__":
    unittest.main()

Then, if you save the above as tests.py you can run the tests using

1
python tests.py

or with pytest as

1
pytest tests.py

If you want to use advanced pytest features, you can read more about them here. For testing of numpy arrays I recommend using the built in test support. To read more about what kind of assert helper unittest provides, see the TestCase docs. A particularly useful helper is for testing that functions fail as expected using e.g. assertRaises as in

1
2
with self.assertRaises(SomeException):
    do_something()
Reflection afterwards
Did you anticipate all the aspects you needed to test? What was missing? Where there useless
tests? Why? Would it have been easier or harder to start without tests?
To top
× Zoomed Image