chapter  15
24 Pages

◾ Writing Good Programs

Learning goal: You can apply some soware engineering techniques that make your programs better. 15.1 IN THIS CHAPTER YOU WILL LEARN

• How to divide a project into smaller tasks

• How to divide a program into functions and classes

• How to use pylint to improve your program code

• How to use Mercurial to keep track of program versions

• How to share your program with other people

• How to improve a program iteratively

• How to build your own modules and packages

15.2.1 There Is Uncertainty in Writing Programs

By now, you probably have already written your first programs. You also understand that programming is a very powerful tool for a scientist. As your skills develop and your programs get more complex, your goal is hidden in a cloud of uncertainty. When you start, you have a certain idea about what your program should do. But as you are writing code, you eventually find out that what you really need is

something else, so you introduce changes to the program. And while you do so, your target keeps moving. As a result, writing a big program resembles a gradual optimization process rather than a straight line. Planning everything in advance is risky and rarely works. Uncertainty is a characteristic of almost all software projects. In contrast, change is a constant: changes will be demanded by your supervisor, by your reviewers, and, most of all, by your own ideas. How can you create a good program under conditions of uncertainty and change? This chapter gives you some engineering practices that can help you create solid, working software.