Difference between Component and Object

10,622

Solution 1

To map it to some real life example,

In a car,

  • An engine is a component
  • Door is a component
  • Key is an object
  • a bolt is an object.

This is over-simplification (and subjective as well ) and I have mentioned it for the sake of simplicity and understanding. A component may be composed of other component as well. But each component serves a very specific purpose (e.g. Engine, Door, Tyre). The objects on the other hand are at more granular level and serve as building blocks of larger components/systems.

Solution 2

Assuming a general software architecture context...

All objects are components, but not all components are necessarily objects.

Components are the general name for elements used in views from the Component-and-Connector Viewtype. The Component-and-Connector Viewtype describes runtime (aka dynamic) views, therefore components are runtime structures (opposed to static structures) (Clements et al., Documenting Software Architectures: Views and Beyond).

A component is not something specific to a particular language, but rather a way of organizing and thinking about the runtime structures of a system so the people developing the system can understand how the system they are building promotes or inhibits specific properties. Therefore, the following are true statements:

  • an object is a component
  • some conceptual collection of objects is a component
  • even a collection of components is a component

How you partition the system into components is going to depend on what meaning you want to convey to your fellow developers and what properties you need your system to achieve. Components connect with one another at runtime -- e.g. one object instantiating another, a web client connecting to a web server, a subscriber registering on an event bus. If you're using an object oriented language like Java, all components will be made up of objects.

Other examples of components, these from Component-and-Connector architectural styles, include tiers (N-Tier style), filters (pipe-and-filter style), objects, and components. "Component" becomes a sort of catch-all in many architecture descriptions so it is better to be more specific when possible.

Solution 3

Components is very general word but generally considering Java-EE architecture design component is group of classes modules met together to server a purpose of the system.

Where object could be a simple entity. Business model

Lets take an example of a Java-EE web application which runs at some bank, So there would be need of User management (roles, registration of user, granting certain roles ..etc..)

where the

User user = new User() would be a single object

Share:
10,622
Kahn
Author by

Kahn

Updated on June 04, 2022

Comments

  • Kahn
    Kahn about 2 years

    What is the key difference between object and component? Can anyone provide examples in Java that how objects and components are related? If possible, please provide some examples whether what are objects and what are components.