Question

In Software engineering , I usually see that the word module when written it usually followed by a bracket (components, packages, classes … etc.) meaning that a module can be a class or a package or a component. I know that a module is a piece of code that do something. I am so confused when to use the word module or class or a package or even a function for my system ??

Was it helpful?

Solution

A module can be an abstract unit of implementation, e.g. larger than an object, perhaps a collection of interacting objects.  Modules are meant to be more loosely coupled with each other than the coupling of their internal components, evoking some notion of independence, e.g. modularity.


The term module is also overloaded with specific meanings in a number of programming languages.


In programming we alternate making abstractions, and using them.  The abstraction ladder includes:

  • variables — abstracting lines of code
  • functions — abstracting lines of code and hidden behind a signature
  • classes — a grouping of related functions and state
  • interfaces — classes related by what they can do
  • modules and namespaces — both of which group classes together into a unit of sorts

OTHER TIPS

A module has a variety of specific meanings in different languages and contexts.

When applied to source code generically, it is typically a way of organising related methods together (a method being a generic word for what specific languages may call routines, functions, or procedures). That is, a module is a division of a whole application or library, which contains one or more methods.

Applied generically to compiled code or executables, the word module has less frequent and consistent usage in my experience, but it's effectively synonymous with library or component.

A class is an object-oriented concept which defines the layout of an object, and also defines and groups a set of associated methods.

Package is not a word common to most languages. In Dotnet and the Microsoft environment generally, there are also grouping elements such as the assembly, project, and solution.

Not all taxonomies are compatible or contain all the same elements by the same name, so in most cases one has to be talking about a specific language or context in order to be precise about what any word means.

Generally a module is a distinct part of something bigger. No more, no less. In software it will often be a packaged file.

The word stems from Latin, meaning measure. Note that creators of software packages and tools may dictate the use of the word for whatever part of their product. It's a handy word in our industry, it could mean different things among products. It sounds a lot fancier and worthy than part.

I mean, what would you rather pay money for? A bit more code in addition to what you already have, or an extra module?

In general a module is something can be loaded independently.

It is valid to say than an executable is a module, it is valid to say that a library loaded dynamically is a module. Although, not very communicative.

In some platforms a class or a function can be a module. Furthermore, some platforms have special names for modules such as package, modules that are part of a system are components.

See also modular design.

Licensed under: CC-BY-SA with attribution
scroll top