Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a little problem with the terms module and component. In my mind, a module are bundled classes, which are only accesable via a well defined interface. They hide all implementation details and are reusable. Modules define modules on which they depend.

What is the difference to components? I looked it up in some books, but the description of components is very similar.

share|improve this question
Which language? Which architecture? Your definition of module works. I think of a component as something that plugs into something for say a GUI while a module can not plug into a GUI; modules can work in a GUI if wrapped/supported by GUI constructs. – Guy Coder Dec 10 '12 at 16:32
See Class vs. Component vs. Control Note: I am not answering because your question does not mention langauge or architecture. – Guy Coder Dec 10 '12 at 16:35
Yes, in this case, I think about the definitions in general – verbose-mode Dec 10 '12 at 16:47
I am not after points, more after making sure you get a valid answer. If you find this valid, then feel free to edit your question and add the link as the answer you prefer. I will not post it as an answer because the question is too general and a specific answer can get others into trouble. – Guy Coder Dec 10 '12 at 16:51
Yeah, I think my question is very general and the answer really depends on the used language or enviornement. Nerver thought there are so much different definitions for these terms – verbose-mode Dec 10 '12 at 16:54
up vote 6 down vote accepted

The terms are similar. I generally think of a "module" as being larger than a "component". A component is a single part, usually relatively small in scope, possibly general-purpose. Examples include UI controls and "background components" such as timers, threading assistants etc. A "module" is a larger piece of the whole, usually something that performs a complex primary function without outside interference. It could be the class library of an application that provides integration with e-mail or the database. It may be as large as a single application of a suite, such as the "Accounts Receivable module" of an ERP/accounting platform.

I also think of "modules" as being more interchangeable. Components can be replicated, with new ones looking like old ones but being "better" in some way, but typically the design of the system is more strictly dependent upon a component (or a replacement designed to conform to that component's very specific behavior). In non-computer terms, a "component" may be the engine block of a car; you can tinker within the engine, even replace it entirely, but the car must have an engine, and it must conform to very rigid specifications such as dimensions, weight, mounting points, etc in order to replace the "stock" engine which the car was originally designed to have. A "module", on the other hand, implies "plug-in"-type functionality; whatever that module is, it can be communicated with in such a lightweight way that the module can be removed and/or replaced with minimal effect on other parts of the system. The electrical system of a house is highly modular; you can plug anything with a 120V15A plug into any 120V15A receptacle and expect the thing you're plugging in to work. The house wiring couldn't care less what's plugged in where, provided the power demands in any single branch of the system don't exceed safe limits.

share|improve this answer
All answers really helped me, but I can only accept one. So I accept KeithS's because he has the lowest rep – verbose-mode Dec 10 '12 at 17:07

The generic meaning of module is a group of reusable code, not tied to one specific program. This could be everything from an entire set of GUI libraries down to a single class.

The generic meaning of component is a module with the additional restriction of substitutability using a specific interface. If you create a GUI Widget component, it can be used anywhere a Widget is expected, without having to do anything special in the calling code. Modules in general have no such restriction. Qt and GTK+ are modules, but I can't swap out one for the other without considerable work in the code calling it, therefore they are not components.

Many frameworks or programming languages use the terms to mean something much more specific, which is why people are asking about context. Something may be a component in the generic sense, but if it doesn't implement a very specific IComponent interface, it may not be considered a component in context. In python, module has the very specific technical meaning of something you can get using an import command. Usually people are referring to these context-specific meanings.

share|improve this answer
Your definition is fine, but your example (Qt vs. GTK+) is flawed (though I agree that I would not call any of them a component, too). IMHO Qt and GTK+ both contain hundreds of small components, thus resulting in a very broad collection of interfaces. That makes it very unlikely that someone will ever invest the time to create an interface compatible replacement for one of them, and that is IMHO the reason why they are no components. However, just because two pieces of software cannot be interchanged does not disqualify them as components, only as components with a common interface. – Doc Brown Dec 10 '12 at 17:53

It depends on your context. Module is already used to refer to DLL level groups in some languages, akin to 'package' or 'assembly' in others. Component is used for COM things as well as Entity Based Component stuff common in game development.

In general architectural terms, module and component do both tend to refer to some bundle of code behind a well defined interface. In general, module tends to refer to larger bundles. There's often a set of interfaces and the module tends to be able to stand on its own.

Components on the other hand tend to be smaller bundles of code, often smaller than a full class. By their name, they tend to be a component of something larger. Sometimes that is the application itself, but with the increasing usage of composition in class design it more often means a component of a larger object. The well defined interfaces for components also tends to allow the app to swap components in for each other. Modules tend not to have that swapability.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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