Modular programming: Difference between revisions

Content deleted Content added
need more words to get the essence: a module provides an aspect of a program; completely and not other aspects
 
(4 intermediate revisions by 2 users not shown)
Line 1:
{{Short description|SoftwareOrganizing designcode techniqueinto modules}}
{{More citations needed|date=June 2022}}
'''Modular programming''' is a [[software development]] mindset that emphasizes separatingorganizing the [[function (programming)|functions]] of a [[codebase]] into independent modules, such that{{endash}} each providesproviding an [[Separation of concerns|aspect]] of a [[computer program]] in its entirety without providing other aspects.
 
A module [[Interface (computing)|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. Modular programming is closely related to [[structured programming]] and [[object-oriented programming]], all having the same goal of facilitating construction of large software programs and systems by [[Decomposition (computer science)|decomposition]] into smaller pieces, and all originating around the 1960s. While the historic use of these terms has been inconsistent, ''modular programming'' now refers to the [[High-level programming language|high-level]] decomposition of the code of a whole program into pieces: ''structured programming'' to the [[Low-level programming language|low-level]] code use of structured [[control flow]], and ''object-oriented programming'' to the ''data'' use of [[Object (computer science)|objects]], a kind of [[data structure]].
Line 28:
In the Java programming language, the term "package" is used for the analog of modules in the JLS;<ref>James Gosling, Bill Joy, Guy Steele, Gilad Bracha, ''The Java Language Specification, Third Edition'', {{ISBN|0-321-24678-0}}, 2005. In the Introduction, it is stated "Chapter 7 describes the structure of a program, which is organized into packages similar to the modules of Modula." The word "module" has no special meaning in Java.</ref> — see [[Java package]]. "[[Java Module System|Modules]]", a kind of set of packages, were introduced in [[Java 9]] as part of [http://openjdk.java.net/projects/jigsaw/ Project Jigsaw]; these were earlier called "superpackages" were planned for Java 7.
 
Conspicuous examples of languages that lack support for modules are [[C (programming language)|C]] and have been [[C++]] and Pascal in their original form, [[C (programming language)|C]] and [[C++]] do, however, allow separate compilation and declarative interfaces to be specified using [[header file]]s. Modules were added to Objective-C in [[iOS 7]] (2013); to C++ with [[C++20]],<ref>{{cite web|url=https://isocpp.org/files/papers/n4720.pdf|title=N4720: Working Draft, Extensions to C++ for Modules}}</ref> and Pascal was superseded by [[Modula]] and [[Oberon (programming language)|Oberon]], which included modules from the start, and various derivatives that included modules. [[JavaScript]] has had native modules since [[ECMAScript]] 2015. [[Precompiled header#Modules (C++)|C++ modules]] have allowed backwards compatibility with headers (with "header units"). Dialects of C allow for modules, for example [[Clang]] supports [[Modules (C++)#Clang C modules|modules for the C language]],<ref>{{Cite web|url=https://clang.llvm.org/docs/Modules.html|title=Modules|website=clang.llvm.org}}</ref> though the syntax and semantics of Clang C modules differ from C++ modules significantly.
 
Modular programming can be performed even where the programming language lacks explicit syntactic features to support named modules, like, for example, in C. This is done by using existing language features, together with, for example, [[coding conventions]], [[programming idioms]] and the physical code structure. [[IBM i]] also uses modules when programming in the [[Integrated Language Environment]] (ILE).
Line 47:
* {{Annotated link|Conway's law}}
* {{Annotated link|Coupling (computer science)}}
* {{Annotated link|Cross-cutting concern}}
* {{Annotated link|David Parnas}}
* {{Annotated link|Information hiding}} (encapsulation)
* {{Annotated link|Library (computing)}}
* {{Annotated link|List of system quality attributes}}
Line 56 ⟶ 57:
* {{Annotated link|Structured analysis}}
* {{Annotated link|Structured programming}}
* {{Annotated link|Cross-cutting concern}}
 
==References==