Definition: A component is a distinct, reusable part of a software system that performs a specific responsibility.
A component usually has a defined interface through which other parts of the system interact with it.
Examples:
- A
PaymentServicecomponent processes payments. - A React
LoginFormcomponent displays and handles login. - A database component stores and retrieves customer information.
Module vs Component
A simple way to remember it:
Module = organizational unit of code
Component = functional building block that interacts with other parts
For example:
E-commerce System
│
├── Payment Module
│ ├── Payment Component
│ ├── Refund Component
│ └── Invoice Component
│
└── User Module
├── Login Component
└── Profile Component
The exact distinction can vary depending on the architecture/framework.