In this chapter, we introduce some programming paradigms designed to improve program structure. As the topics addressed by this chapter are vast, we shall provide only overviews and then references to literature containing more thorough descriptions and evaluations of the relative merits of the various approaches.

Structured programming is all about managing complexity. Modern computational approaches in all areas of science are intrinsically complicated. Consequently, the efficient structuring of programs is vitally important if this complexity is to be managed in order to produce robust, working programs.

Historically, many different approaches have been used to facilitate the structuring of programs. The simplest approach involves splitting the source code of the program between several different files, known as compilation units. A marginally more sophisticated approach involves the creation of namespaces, allowing variable and function names to be categorised into a hierarchy. More recently, an approach known as object-oriented (OO) programming has become widespread. As we shall see, the F# language supports all of these approaches as well as others. Consequently, F# programmers are encouraged to learn the relative advantages and disadvantages of each approach in order that they may make educated decisions regarding the design of new programs.

Structured programming is not only important in the context of large, complicated programs. In the case of ...

Get F# for Scientists now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.