eWebProgrammer
Distributednetworks GofPatterns
prev next prev next
  Course Navigation
 
Lesson 6
Objective
EJB Reusable Components
Reusable components/ identify when it is appropriate
   
Describe a reusable component and identify when it is appropriate to employ one.
There is a lot of talk in the media about components and component architectures as being the current best practices in developing modern systems.
So what are components ?
How do components help us to develop flexible systems?
Component definition
A component is a physical and replaceable part of a system that provides a service and conforms to, and provides a realization of, a set of interfaces.
This definition comes from UML Users Guide which is available from the Book Store . page.
Note that the term realization is used in a similar manner as,
"I have realized my dream," which means you have turned your dream into something real or concrete.
Thus, diagrammatically, we can represent a component as having two parts:
  1. One or more interfaces which collectively form the "interface"
  2. The concrete realization
Realization : The concrete implementation of one or more interfaces.
Component definition
The parts are separate…
The two parts of a component are separate and can be considered, to a certain degree, independently.
The client is dependent on the interface, not the implementation.
The interface provides a specific service through methods that take parameters and return values.
These methods are invoked by messages sent from a client.
The implementation (a specific realization) is coupled to, but independent of, the interface.
Thus, as long as the realization implements the interface methods,
it can achieve that functionality any way it needs to.
Think of it like a starter motor for your car.
When you need a new starter motor for your car, you can go to the dealer or you can go to one of many third-party suppliers and manufacturers that will sell you one that will work.
Implement: An object that provides a realization of a particular interface is said to implement that interface.
The point is that all starter motors for your particular car will work.
They support a common interface (mounting points, voltage, performance, etc.) and provide a similar service.
You will choose the one you actually buy based on price, reputation, reliability, availability, convenience, etc.
The specific starter motor you buy is a "realization" of the interface designed into your car.
Imagine if you had to get a particular starter motor that had to be custom built for your car.
Or even one that was built into the engine and was not a separate component, and was only available from the dealer.
It would cost a fortune and you would be at the mercy of the supplier!
To avoid this, we use replaceable components to build our applications, giving us low cost and flexibility.
Distributed Systems Basics
The link below contains more information regarding parts of a distributed object system.
Distributed Systems Basics
In the next lesson, you will be introduced to Object Monitors.
  Course navigation