Professional Documents
Culture Documents
UNIT – II
2.1 COMPONENTS
It is a marketable entity
o A Component is a self-contained, shrink-wrapped, binary piece of software
that can be purchased in an open market.
It is an interoperable object.
o A Component is a system independent software entity. It can be invoked
across address spaces,networks,languages and operating systems.
It is an extended object.
o Components can support encapsulation,inheritance and polymorphism.
2.4.1 Interfaces:
An interface defines the communication boundary between two entities, such as a
piece of software, a hardware device, or a user. It generally refers to an abstraction
that an entity provides of itself to the outside. This separates the methods of external
communication interface.
Interfaces between hardware components are physical interfaces.
An interface is a set of named operations that can be invoked by clients. Each
operation’s semantics is specified, and this specification plays a dual role as it serves
both providers implementing the interface and clients using the interface.
The Specification of the interface is the mediator that allows two parties to work
together. A component specification names all interfaces that a component should adhere to
and adds component-specific properties.
Filter example:
Two interfaces may be used for the input and output sides of a filter component.
The filter specification would then say that the output is related to the input.
Interaction between components can be focused by using certain interfaces.
This is done by writing specifications that constrain data flow through the given set of
interfaces.
Interfaces appear as the endpoints of Interaction specification and no interface can
appear in more than one interface specification.
Components must be separated from its interfaces and interface specifications.
Method dispatch can lead to the involvement of third party, about which the calling
client and the interface introducing component are unaware.
Object implementing the interface belongs to a component (ie.,Third party) that is
different from the component(ie.,Target component) with which the client seems to
interact through the interface.
EXAMPLE
2.6 VERSIONS
The goal is to ensure that older and newer components are either compatible or clearly
detected as incompatible.
The general strategy is to support a sliding window of supported versions.
The client has to establish the precondition before calling the operation.
The provider can rely on the precondition being met whenever the operation is called.
The provider has to establish the post condition before returning to the client.
The client can rely on the post condition being met whenever the call to the operation
returns.
2.8 CALLBACKS
Fig.2.1 Call sequence between library and client in the presence of callbacks.
In the presence of callbacks, the situation changes. The intermediate library state at
the point of calling the callback may be revealed to clients.
A library thus has to be careful to establish a “valid” state, before invoking any
callbacks.
A callback may cause the library’s state to change through direct or indirect calls to
the library.
Hence, the observable state of the library has to remain “valid” for as long as any
callbacks are active.
Validity of the library state is specified as part of the contract.
A directory service is the software system that stores and organizes information in a
directory and provide access to that information.
Consider a file system providing a basic directory service.
The directory service supports callbacks to notify the clients about changes in the
managed directory.
Such a notification service is useful to keep a visual representation of the directory up
to date.
Most current file systems do not support notification, and the applications are
therefore forced to poll the file system to discover changes.
The example below is written in Pascal. The simple directory service interface is
grouped into two parts.
a. The first part supports file look up, addition and deletion of named files.
b. The second part supports registration and unregistration of callbacks.
Early programming languages attempted to provide all functions that should be used
in multiple programs.which lead to explosion of built-in functions.
As a result,specific functionalities were removed from the programming languages
and they are defined as abstractional and structural features.
This lead to the birth of modular languages.Proven solutions are grouped into modular
libraries or toolboxes.Eg: Modula2.
Libraries are generally layered on top of each other.
As the components are combined freely,the contract between providers and clients
gains importance.
The contract must be crafted carefully so that providers and clients from fully
independent sources will be able to interact properly.
Interfaces with their associated contracts are logically the smallest contractual unit in
the system.
Interfaces reside at the endpoint of interactions.
An interface definition may refer to the client end or the provider end.
Same provides interface can be implemented by many providers.
Any particular instance of a provides interface is associated with logical provider.
The logical provider may correspond to one module(Direct Interface) or one object
(Indirect interface).
Sets of interfaces can be bundled into composed contracts.
An atomic interface bundles a set of operations that share the direction of invocation.
A composed contract can combine interfaces of varied directionality and multiple
logical providers.
Design patterns are microarchitectures. They describe the abstract interaction between
objects collaborating to solve a particular problem.
Once the problem has been isolated, a proper pattern can be chosen. The pattern then
needs to be adapted to the specific circumstances.
In the Observer pattern example, It defines a one-to-many dependency between
objects. This is that when the one object (the subject) changes, all its dependents (the
observers) are notified to perform updates as required.
Patterns can be defined using the following four elements.
o A pattern name.
o The problem that the pattern solves.
o The solution to the problem brought by the pattern.
Elements involved and their roles, responsibilities, relationships, and collaborations.
Not a particular concrete design or implementation.
o The consequences (results and tradeoff) of applying the pattern.
Time and space tradeoff.
Language and implementation issues.
Effects on flexibility, extensibility, portability.
The “onion model” emphasizes the encapsulating property of strict layers, but
introduces a bias toward the expected relative size of the layers. There is no strict
technical need for lower layers to be “smaller” than higher ones.
A layered system can be understood incrementally, layer by layer, whether bottom up
or top down.
This is possible because each layer can be fully understood by understanding its
implementation, relative to the interfaces it uses from the layer mmediately below,
and the interfaces it offers to the layer immediately above.
It hinders extensibility and it can introduce unacceptable performance penalties.
Extensibility is threatened because a new, higher-level component can only be build
on what is provided by the next, lower layer.
The idea of extensible ,layered architecture is that every extension should still reside
on a single layer.
If an extension on one layer needs to access services of a layer below the next lower
layer,then intermediate extensions need to be devised. The format of Extensible strict
layering is shown in fig.2.4.
The practice of accessing not only the next lower layer but also any of the lower
layers leads to non-strict layering.
Non strict Layering can solve extensibility and performance problems by eliminating
intermediate layers.
In pull model the consumers call the pull method of the event channel, effectively
polling the channel for events.
Structure of analogy with ICs is shown in Fig.2.5. ICs have various pins, some of
which carry input and others of which carry output signals.
Connection-oriented programming requires symmetry of connection points (ports) for
input and output.
The corresponding interfaces are called incoming and outgoing interfaces or provided
and required interfaces.
An incoming interface corresponds to traditional procedural or method interfaces.
Declaring outgoing interfaces of a component corresponds to declaring the events or
messages that this component could emit.
Every interface defines a clear call direction from interface client (caller) to interface
provider (callee).
Component object C1 has outgoing interfaces B and V and incoming interfaces A and
U.
Component object C2 has outgoing interfaces A and Y and incoming interfaces B and
X.
Connections have been established between the A and B interfaces of the two
components.
2.10.6 COMPOSITES
A component framework may provide a common layer that defines various interfaces.
A component belonging to this framework imports the common layer and declares
which of these interfaces it uses in incoming, outgoing, or both roles. The structure of
composites of ICs is shown in fig.2.6.
Such a separate connection layer or the connected objects may need to provide
permanent connections.
Composites are objects that control the creation and connection of other objects.
A composite instance does not contain the objects it creates and connects.
Connection-oriented programming is a particular programming style that is especially
useful when aiming for component-oriented programming.
Fig.2.7 A multilayer architecture with three tiers – components, component frameworks, and a
component system.
2.14 COMPOSITION
Elements declare their constraints on acceptable contexts, but do not construct the
context.
Composition assumes well-formed contexts, minimizing the burden of describing and
handling exceptional conditions.
Composites have certain properties by construction, as long as they have been formed
using one of the valid composition rules.
All current component “wiring” standards use one or another form of event
propagation as one particularly flexible form of component instance assembly. Component
instances that undergo a state change of expectedly wider interest post an event object.
A separate event distribution mechanism accepts such event objects and delivers them
to other component instances that have registered their interest. Component instances register
their interest, because they may have to update their state to adjust to the changes indicated
by the event object.
Multithreading
Multithreading is the concept of supporting multiple sequential activities concurrently
over the same state space. The resulting increase in complexity over sequential programming
is substantial.
The main focus of multithreading is the better distribution of performance as observed
by clients issuing concurrent requests.
Nutshell classes
Nutshell classes are themselves abstract, although all methods are implemented as it
simply makes no sense to instantiate such a class.
Language support
Language support is where the programming language directly supports construction
of a forwarder class.
The programming overhead is minimal and the runtime overhead in time and space
has to be no different from that of implementation inheritance schemes.
Caller encapsulation
Another area that benefits from language support is that of interface definitions.
When exposing an interface on a component boundary, two different intentions may
be involved.
On the one hand, component-external code may need to invoke operations of the
exposed interface.
On the other hand, component- internal code may need to invoke operations that
implement the exposed interface. In COM terminology, this is the difference between
incoming and outgoing interfaces.
Components are units of deployment, deployable by third parties, but are never
deployed in isolation.
Component instances interact with each other, usually mediated by one or more
component frameworks.
2.19.1 Systematic initialization and wiring
Architecture description languages (ADLs) follow this idea: they typically have
components and connectors as their core repertoire.
Composition is expressed as selecting components and interconnecting those
using selected connectors. Any such composition really describes how instances of
the selected components should be “wired up” using instances of the selected
connectors.
BML (Bean Markup Language) is a JavaBeans composition language released by the
IBM alphaWorks.
BML is an XML-based component configuration or wiring language customized for
the JavaBean component model.
Using XSLT, BML can be the target of transformations from more abstract
descriptions.
JavaBeans components, for example, can distinguish between use and build-time of
their instances.
A “bean” can therefore exhibit special looks, such as building block icons; behavior,
such as handles to connect instances to others; and guidance, such as dedicated online
help to assist assembly personnel.
During assembly, components are instantiated, and instances are connected using a
uniform approach to connectable objects with outgoing and incoming interfaces. Both
JavaBeans and COM support general connection paradigms for this purpose.
A script is essentially a small program – usually a procedure – that intercepts an event
on its path from source to sink and triggers special actions.
The prototypical application builder supporting a dedicated scripting language is
Visual Basic, although Apple’s Hypercard was a precursor.
Component instances are naturally visual (provide a visual user interface), dedicated
builders or assembly environments can be unified with environments for regular use.
With compound documents, integration of build and use environments is
straightforward and natural – documents are applications and document editing is
component (instance) assembly.
Seamless integration of build and use environments, especially in the context of
compound documents, forms the strongest and most productive case for rapid
application development (RAD).
In such environments, production- quality components, prototype components, and
throwaway use-once solutions can be freely combined.
Requirements capturing and change request validation can be performed efficiently
and effectively in this setting.
A common application for this can be found in compound document systems – form
templates.
A form template is a document that is copied each time that a fresh form, ready to be
filled in, needs to be created.
Self-guided assembly is similar, but uses rules that are carried by the component
instances themselves.
For example, a component instance could form a “mobile agent,” which is an entity
that migrates from server to server and aggregates other component instances to
assemble functionality based on the findings at the various servers.
TWO MARKS
1) Define software component.
A component i s a collection of objects that provide a set of services to other systems.
Components may be run either locally or in a distributed fashion. The Object Linking
and Embedding (OLE) architecture is an example.
3) What are the benefits we get by developing applications using software components?
7) Define Versioning.
A contract has two sides – the client and the provider. Contracts are established by
specifying the pre- and post-conditions for the operations.
The client has to establish a pre-condition before calling the operation. The provider
ensures that the pre-condition is met when the operation is called.
The provider establishes the post-condition before returning to the client.
The contract can thus be represented as a triple {pre-conditions} operation {post-
condition}.
Callbacks are functions that are set up by the programmers to react to signals emitted
by widgets (user interfaces).
The call backs are thus pre-defined or user-defined signal handlers. Call backs have to
be registered to be used.
A call back is a procedure that is registered with a library at one point. In times of
need, the library calls these callback procedures.
The reach and viability of components are much increased by enabling simpler forms of
assembly to cover most common component applications. Types of assembly are:
Visual component assembly
Managed and self-guided component assembly
End-user assembly