Wednesday, 8 January 2014

Objects Vs Components


  • An object is an real programmatic entity i.e. an instance of class.
  • However, a component can consist of more than one object.
  • Component is a more abstract term. e.g. webserver is a component of an enterprise architecture or button is a component.
  • Usually components encapsulate some reusable functionality, are autonomous but can be connected to other components. Objects can as well do this but
  • Objects are, next to primitive types but components are usually bigger and have more common functions.
Quoting from wikipedia:



A software component is a system element offering a predefined service and able to communicate with other components. Clemens Szyperski and David Messerschmitt give the following five criteria for what a software component shall be to fulfill the definition:
  1. Multiple-use
  2. Non-context-specific
  3. Composable with other components
  4. Encapsulated i.e., non-investigable through its interfaces
  5. A unit of independent deployment and versioning.


Yet another definition is:
A component is an object written to a specification. It does not matter what the specification is: COM, Java Beans, etc., as long as the object adheres to the specification. It is only by adhering to the specification that the object becomes a component and gains features like reusability and so forth.
So, the difference between component & object is essentially a perspective difference.

More importantly, components do not support inheritance whereas objects do.

(Adapted from: 
http://forums.devx.com/showthread.php?s=2aa11bf305df7a0bc38815911cfb259b&t=25304
)

No comments:

Post a Comment