22

According to Stephen Schach, “Classical and Object-Oriented Software Engineering”, chapter 6:

a module consists a single block of code that can be invoked in the way that a procedure, function, or method is invoked

This seems very vague and broad. So could anyone explain it clearly and show some actual examples of how to break a requirement into modules? Thanks.

0

3 Answers 3

17

A module,

  • encapsulates code and data to implement a particular functionality.
  • has an interface that lets clients to access its functionality in an uniform manner.
  • is easily pluggable with another module that expects its interface.
  • is usually packaged in a single unit so that it can be easily deployed.

For example, dapper.net encapsulates database access. It has an API to access its functionality. It is a single file that can plugged in a source tree to be built.

The concept of module comes from modular programming paradigm which advocates that software should be composed of separate, interchangeable components called modules by breaking down program functions into modules, each of which accomplishes one function and contains everything necessary to accomplish this.

2
  • if we have a bunch of requirements so each requirement can be considered as a module ? Eg: the requirement "Adding employee" can be a module ?
    – Hoan
    Oct 7, 2012 at 9:30
  • 1
    No or it depends. Program functions should be broken down into cohesive units. If the requirements can be broken down in such way, may be yes. But I haven't seen anything like this yet. Also, "Adding Employee" should not be a candidate for module. Usually modules are higher level structures which decompose programs into logically coherent units.
    – theD
    Oct 7, 2012 at 9:46
15

Module might be an overloaded term, so much that Wikipedia describes it under the term Modular Programming when discussing its use relative to software. They discuss it in terms of structured programming which was based on a top-down design approach. Key characteristics of modularity related to the use of low coupling and high cohesion.

My usage has been that in a language like C or even C++, a module is related to defining a separately compiled unit from a source file (.c or .cpp) and typically one associated header file (.h). Other languages use module as a description, and the language Modula-2 put structuring around modules front and center in its name and its approach.

Historically, module has some other implications as were described in the D.L. Parnas paper "On the Criteria to be Used in Decomposing Software into Modules". He is primarily concerned with discussing benefits of replacing functional decomposition with data oriented decomposition which was a big step toward our present state of the art which is object oriented decomposition.

Object oriented languages are organized around classes, so maybe the term module is less important and less precise in that context.

1
  • do you have a preferred reference to review functional decomposition -> data oriented decomposition -> object oriented decomposition? Something with examples of each paradigm would be really educational, thanks! Aug 24, 2021 at 19:34
9

There isn't a formal definition of a module, and what a module is (or isn't) in the context of your project largely depends on the nature and design of the project.

Generally speaking a module is a standalone piece of code that provides specific and tightly coupled functionality, modules define and enforce logical boundaries in your code.

Not the answer you're looking for? Browse other questions tagged or ask your own question.