ArticleslgStudy

science

Modular programming

Modular programming is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Modular programming rather than just read about it. In short: Modular programming is a programming paradigm that emphasizes organizing the functions of a codebase into independent modules, each providing an aspect of a computer program in its entirety without providing other aspects. A module interface expresses the elements that are provided and required by the module.

Key takeaways

  • Modular programming belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Modular programming to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Modular programming from memory before moving on to harder problems.

Reference excerpt

Modular programming is a programming paradigm that emphasizes organizing the functions of a codebase into independent modules, each providing an aspect of a computer program in its entirety without providing other aspects. A module interface expresses the elements that are provided and required by the module. The elements defined in the interface are detectable by other modules. The implementation contains the working code that corresponds to the elements declared in the interface.

History Modular programming, in the form of subsystems (particularly for I/O) and software libraries, dates to early software systems, where it was used for code reuse. Modular programming per se, with a goal of modularity, developed in the late 1960s and 1970s, as a larger-scale analog of the concept of structured programming (1960s). The term "modular programming" dates at least to the National Symposium on Modular Programming, organized at the Information and Systems Institute in July 1968 by Larry Constantine; other key concepts were information hiding (1972) and separation of concerns (SoC, 1974). This resembles the pattern language approach of Design patterns promoted in the book Design Patterns: Elements of Reusable Object-Oriented Software (1994) by the so-called "Gang of Four" (Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides). Modules were not included in the original specification for ALGOL 68 (1968), but were included as extensions in early implementations, ALGOL 68-R (1970) and ALGOL 68C (1970), and later formalized. One of the first languages designed from the start for modular programming was the short-lived Modula (1975), by Niklaus Wirth. Another early modular language was Mesa (1970s), by Xerox PARC, and Wirth drew on Mesa as well as the original Modula in its successor, Modula-2 (1978), which influenced later languages, particularly through its successor, Modula-3 (1980s). Modula's use of dot-qualified names, like M.a to refer to object a from module M, coincides with notation to access a field of a record (and similarly for attributes or methods of objects), and is now widespread, seen in C++, C#, Dart, Go, Java, OCaml, and Python, among others. Modular programming became widespread from the 1980s: the original Pascal language (1970) did not include modules, but later versions, notably UCSD Pascal (1978) and Turbo Pascal (1983) included them in the form of "units", as did the Pascal-influenced Ada (1980). The Extended Pascal ISO 10206:1990 standard kept closer to Modula2 in its modular support. Standard ML (1984) has one of the most complete module systems, including functors (parameterized modules) to map between modules. In the 1980s and 1990s, modular programming was overshadowed by and often conflated with object-oriented programming, particularly due to the popularity of C++ and Java. For example, the C family of languages had support for objects and classes in C++ (originally C with Classes, 1980) and Objective-C (1983), only supporting modules 30 years or more later. Java (1995) supports modules in the form of packages, though the primary unit of code organization is a class. However, Python (1991) prominently used both modules and objects from the start, using modules as the primary unit of code organization and "packages" as a larger-scale unit. Perl 5 (1994) also includes support for both modules and objects, with a vast array of modules being available from CPAN (1993). OCaml (1996) followed ML by supporting modules and functors. Modular programming is now widespread, and found in virtually all major languages developed since the 1990s. The relative importance of modules varies between languages, and in class-based object-oriented languages there is still overlap and confusion with classes as a unit of organization and encapsulation, but these are both well-established as distinct concepts.

Terminology The term assembly (as in .NET languages like C#, F#, or Visual Basic) or package (as in Dart, Go, or Java) is sometimes used instead of module. In other implementations, these are distinct concepts; in Python a package is a set of modules, while in Java 9 the introduction of the Java Platform Module System, in which a new module concept, involving a set of packages with enhanced access control, was implemented. (These packages are not the same as other sorts of packages in software, such as package manager packages.) In Java, the term package is used for the module concept in the Java language specification. The module, a kind of set of a package, was introduced in Java 9. In some Pascal dialects, the term unit is used for the module concept. A component is a similar concept, but typically refers to a higher level; a component is a piece of a whole system, while a module is a piece of an individual program. The scale of the term "module" varies significantly between languages; in Python it is very small-scale and each file is a module, while in Java 9 it is large-scale, where a module is a set of packages, which are in turn sets of files.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Modular programming

Start with the simplest possible case. Write down what Modular programming claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Modular programming before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Modular programming ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Modular programming

In research
Modular programming appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Modular programming in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Modular programming is common in secondary-school and first-year university syllabi. It links to neighbouring topics Modularity, Programming paradigms, so understanding it makes those chapters shorter.
In everyday life
Look for Modular programming outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Modular programming” →

How to study Modular programming in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Modular programming means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Modular programming out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Modular programming in simple terms?

Modular programming is a programming paradigm that emphasizes organizing the functions of a codebase into independent modules, each providing an aspect of a computer program in its entirety without providing other aspects. A module interface expresses the elements that are provided and required by…

Why does Modular programming matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Modular programming?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Modular programming.

Tags

  • Modularity
  • Programming paradigms

Keep exploring