Download Full Component Oriented Development and Assembly Paradigm Principles and Practice using Java 1st Edition Piram Manickam PDF All Chapters
Download Full Component Oriented Development and Assembly Paradigm Principles and Practice using Java 1st Edition Piram Manickam PDF All Chapters
https://ebookultra.com/download/object-oriented-software-development-
using-java-principles-patterns-and-frameworks-2nd-edition-xiaoping-
jia/
https://ebookultra.com/download/object-oriented-software-engineering-
using-uml-patterns-and-java-2nd-edition-bernd-bruegge/
https://ebookultra.com/download/rural-development-principles-and-
practice-1st-edition-malcolm-j-moseley/
https://ebookultra.com/download/object-oriented-design-with-uml-and-
java-1st-edition-kenneth-barclay/
Java EE 5 Development using GlassFish Application Server
1st Ed. Edition David Heffelfinger
https://ebookultra.com/download/java-ee-5-development-using-glassfish-
application-server-1st-ed-edition-david-heffelfinger/
https://ebookultra.com/download/automatic-ecg-analysis-using-
principal-component-analysis-and-wavelet-transformation-antoun-
khawaja/
https://ebookultra.com/download/evaluating-the-effectiveness-of-
academic-development-principles-and-practice-1st-edition-lorraine-
stefani/
https://ebookultra.com/download/china-s-rise-development-oriented-
finance-and-sustainable-development-1st-edition-lixing-zou/
https://ebookultra.com/download/java-the-uml-way-integrating-object-
oriented-design-and-programming-else-lervik/
Component Oriented Development and Assembly
Paradigm Principles and Practice using Java 1st Edition
Piram Manickam Digital Instant Download
Author(s): Piram Manickam, S. Sangeetha, S. V. Subrahmanya
ISBN(s): 9781466581005, 146658100X
Edition: 1
File Details: PDF, 15.41 MB
Year: 2013
Language: english
Component-
Oriented
Development
and Assembly
Paradigm, Principles, and
Practice Using Java
Piram Manickam
S. Sangeetha
S. V. Subrahmanya
Component-
Oriented
Development
and Assembly
Paradigm, Principles, and
Practice Using Java
In an initiative to promote authorship across the globe, Infosys Press and CRC Press have
entered into a collaboration to develop titles on leading edge topics in IT.
Infosys Press seeks to develop and publish a series of pragmatic books on software
engineering and information technologies, both current and emerging. Leveraging Infosys’
extensive global experience helping clients to implement those technologies successfully,
each book contains critical lessons learned and shows how to apply them in a real-world,
enterprise setting. This open-ended and broad-ranging series aims to brings readers practical
insight, specific guidance, and unique, informative examples not readily available elsewhere.
Applying Resource Oriented Architecture: Using ROA to Build RESTful Web Services
G. Lakshmanan, S. V. Subrahmanya, S. Sangeetha, and Kumar M. Pradeep
Piram Manickam
S. Sangeetha
S. V. Subrahmanya
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
© 2014 by Taylor & Francis Group, LLC
CRC Press is an imprint of Taylor & Francis Group, an Informa business
This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been
made to publish reliable data and information, but the author and publisher cannot assume responsibility for the valid-
ity of all materials or the consequences of their use. The authors and publishers have attempted to trace the copyright
holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this
form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may
rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or uti-
lized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopy-
ing, microfilming, and recording, or in any information storage or retrieval system, without written permission from the
publishers.
For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://
www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923,
978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For
organizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for
identification and explanation without intent to infringe.
Visit the Taylor & Francis Web site at
http://www.taylorandfrancis.com
and the CRC Press Web site at
http://www.crcpress.com
This book is dedicated to our mentor Mr. Kris S. Gopalakrishnan,
Vice Chairman of Infosys Limited
Fo re wo rd xiii
P r e fa c e xv
Acknowledgments xvii
Th e A u t h o r s xix
Pa r t I P r i n c ip l e s : C o n c e p t s in CODA
Chapter 1 I n t r o d u c t i o n t o C o m p o n e n t- O r i e n t e d D e v e l o p m e n t
a n d A s s e m b ly (CODA ) 3
1.1 Introduction 3
1.2 Motivation for Software Components 3
1.3 Components—An Ice Breaker 4
1.4 Component Characteristics 5
1.4.1 Part of a Whole 5
1.4.2 Component Ecosystem 5
1.4.3 Component Framework 5
1.4.4 Component Model 6
1.4.5 Component Interfaces 6
1.4.6 Provided and Required Interfaces 6
1.4.7 Component Compatibility 6
1.4.8 Implementation Independence 7
1.4.9 Producer-Consumer Independence 7
1.4.10 Active and Passive Component 7
1.5 Historical Perspective of Software Components 7
1.6 Defining Software Components 8
1.6.1 Function Libraries as Software Components 10
1.6.2 Object Libraries as Software Components 10
1.7 Elements of a Software Component 11
1.7.1 Component Specification 12
1.7.2 Component Interfaces 12
C h a p t e r 2 C o m p o n e n t Th i n k i n g in J ava 21
2.1 Introduction 21
2.2 Component Constructs in Java SE 21
2.3 Java Software Components Using JAR and Package 23
2.4 Java Interfaces to the Rescue of Build Time Tight Coupling 25
2.5 Runtime Dependencies While Using Interfaces 27
2.6 Manual Component Assembly Using Glue Code 28
2.7 Automated Component Assembly Using Component Framework 29
2.8 Example Component Model 29
2.9 Summary 33
Review Questions 34
C h a p t e r 3 C o m p o n e n t M o d e l s in J ava 35
3.1 Introduction 35
3.2 Understanding Components 35
3.3 Enterprise JavaBeans Component Model 36
3.3.1 Business Interface 37
3.3.2 EJB Component 37
3.3.3 EJB Container 38
3.3.4 Component Reference 38
3.3.5 An Example to Understand the EJB Component Model 39
3.4 Spring Component Model 42
3.4.1 Spring Container 42
3.4.2 Spring Beans 43
3.4.3 Spring Configuration 43
3.4.4 An Example to Understand the Spring Component Model 44
3.5 OSGi Component Model 46
3.5.1 OSGi Bundle 47
3.5.2 OSGi Service Registry 48
3.5.3 OSGi Component 48
3.5.4 An Example to Understand the OSGi Component Model 49
3.5.4.1 Interface Bundle 50
Architecture 67
4.1 Introduction 67
4.2 Componentizing a Monolithic Application 67
4.2.1 Analysis of the Monolithic Implementation of the Virtual Store 67
4.2.2 Componentizing the Virtual Store 69
4.2.3 Analysis of the Componentized Implementation of the Virtual Store 70
4.2.4 Accommodating Changes to the Virtual Store 73
4.3 Componentizing Applications with Multiple Layer Architecture 75
4.3.1 Existing Design of the POS Layered Application 76
4.3.1.1 Objects in the Model 76
4.3.1.2 Design of the Presentation Layer 77
4.3.1.3 Design of the Business Layer 77
4.3.1.4 Design of the Persistence Layer 78
4.3.2 Analysis of the Existing Design of the POS Application 79
4.3.3 Componentizing the POS Application 80
4.3.4 Component Replacement in the POS Application 81
4.4 Summary 86
Review Questions 86
Chapter 5 P r a c t i c i n g CODA with OSG i 87
5.1 Introduction 87
5.2 What Is OSGi? 87
5.3 Necessity of OSGi 88
5.4 The OSGi Module Layer 91
5.4.1 Internal Bundle Class Path 92
5.4.2 Exported Internal Code 93
5.4.3 Imported External Code 93
5.5 OSGi Runtime Framework 96
5.6 OSGi Life Cycle Layer 97
5.7 OSGi Service Layer 100
5.8 OSGi Declarative Services Specification 102
5.9 Summary 106
Review Questions 106
Chapter 6 P r a c t i c i n g CODA with SCA 109
6.1 Introduction 109
6.2 What Is Service Component Architecture? 109
C h a p t e r 7 E n t e r p r i s e C o m p o n e n t- O r i e n t e d D e v e l o p m e n t a n d
A s s e m b ly U s i n g J ava P l at f o r m , E n t e r p r i s e E d i t i o n 125
7.1 Introduction 125
7.2 Presentation Tier Components 125
7.2.1 Web Component Model—Java Servlet 126
7.2.2 Web Component Model—Java Server Pages 128
7.2.3 Web Component Model—Java Server Faces 129
7.2.4 Web Container 132
7.2.5 Packaging Web Components 132
7.3 Business Tier Components 134
7.3.1 Business Interface 134
7.3.2 EJB Container 135
7.3.3 Enterprise JavaBean Component Types 135
7.3.3.1 Stateless Session Beans 135
7.3.3.2 Stateful Session Beans 137
7.3.3.3 Singleton Session Beans 138
7.3.3.4 Message-Driven Beans 138
7.3.4 Packaging Enterprise JavaBean Components 140
7.3.5 Accessing Enterprise JavaBean Components 140
7.4 Persistence Tier Components 143
7.4.1 Entity 144
7.4.2 Entity Manager 146
7.4.3 Persistence Provider 147
7.4.4 Packaging Entities 147
7.4.5 Accessing Entities 148
7.5 Enterprise CODA Using Java EE—An Example 150
7.6 Summary 154
Review Questions 154
C h a p t e r 8 E n t e r p r i s e C o m p o n e n t- O r i e n t e d D e v e l o p m e n t and
A s s e m b ly U s i n g t h e S p r i n g C o m p o n e n t M o d e l 157
8.1 Introduction 157
8.2 Spring Component Model 157
8.3 Spring Container 159
8.4 Spring Beans 160
8.5 Spring Configuration 160
8.6 Spring MVC Model 161
A s s e m b ly U s i n g E n t e r p r i s e OSG i 181
9.1 Introduction 181
9.2 Enterprise OSGi—An Introduction 181
9.3 Enterprise OSGi—Application Structure 182
9.4 Web Application Service 183
9.5 Blueprint Container Specification 184
9.6 JPA Service 188
9.7 Enterprise CODA Using Enterprise OSGi—An Example 189
9.7.1 Persistence Bundle 190
9.7.2 Blueprint Bundle 194
9.7.3 Web Application Bundle 196
9.8 Summary 198
Review Questions 199
Pa r t III Pa r a d i g m : C o m p o n e n t Te s t i n g , B u s i n e s s
A pp l i c at i o n C a s e S t u dy, a n d To o l s
C h a p t e r 10 Te s t i n g C o m p o n e n t- O r i e n t e d S o f t wa r e 203
10.1 Introduction 203
10.2 Concepts in Software Testing 203
10.3 Concepts in Component-Oriented Software Testing 204
10.4 Validation of Component Interfaces 205
10.4.1 Example of White-Box Validation 205
10.4.2 Example of Black-Box Validation 206
10.5 Verification of Component Implementation—White-Box Testing 207
10.6 Verification of Component Functionality—Black-Box Testing 211
10.6.1 Test Case for the Number of Tables 212
10.6.2 Test Case for the Occupy Table Functionality 213
10.6.3 Test Case for the Empty Table Functionality 214
10.7 Summary 216
Review Questions 216
C h a p t e r 11 I m p l e m e n t i n g a B u s i n e s s A pp l i c at i o n U s i n g
CODA — A C a s e S t u dy 217
11.1 Introduction 217
11.2 Case Study Problem—Point-of-Sale Application for Restaurants 217
11.2.1 Use Case 1—Configure Dining Tables 218
11.2.2 Use Case 2—Create New Menu Item 218
11.2.3 Use Case 3—Modify/Remove Existing Menu Item 218
11.2.4 Use Case 4—Check-In Guests 218
11.2.5 Use Case 5—Place Order 220
11.2.6 Use Case 6—Modify/Cancel Order 220
will ultimately risk leaving without success and in frustration. It is for this very reason
that Component-Oriented Development and Assembly is a timely collection of observations,
insights, and understandings that provides the appropriate structure and sheds the
needed light on this important topic. The authors provide a carefully thought out
treatment of software components and component-oriented development. They do so
in a m
anner that is, at the same time, rigorous and accessible to a spectrum of read-
ers: from those who are generally knowledgeable in software engineering but do not
have a background in component-oriented development, to those who have significant
prior exposure but are looking to shore up their knowledge and develop expertise in
the state-of-the-art. Simply put, Component-Oriented Development and Assembly will be a
valuable addition to any software engineer’s bookshelf!
Professor Nenad Medvidović
Professor and Associate Chair for Ph.D. Affairs
Computer Science Department
University of Southern California
Author of the Book— Software Architecture: Foundations, Theory, and Practice
Part II focuses on educating readers with various standard Java component m odels
and describing how to develop a component-oriented system using these c omponent
models. The second part opens with a chapter on the design and architecture of
component-oriented software. This is followed by chapters that cover various Java
component models such as OSGi, SCA, Java EE, Spring, and Enterprise OSGi in
depth. Each technology is explained with the help of implementation. All of the
chapters make use of the same application scenario to elaborate on component-
oriented solutions. This makes it easy to follow the example implementations in
different chapters as well as helps the reader to compare and contrast the differences
across implementations in different component models. OSGi and SCA are authorita-
tive organizations that define g uidelines for the component world. This book adheres
to the guidelines set up by them.
Part III presents various aspects of the component-oriented development para-
digm. The first chapter in this part deals with testing and quality assurance aspects
of component-oriented software. The next chapter provides an end-to-end case study
of a real-life business problem that is solved using the CODA approach. The last
chapter provides input on how the use of tools can bolster the CODA approach. In
this chapter, a fictitious component workbench is presented, and the software compo-
nents from the case study are assembled using this tool.
Overall, the book provides enough information for anyone to start practicing
CODA. We believe this book is appropriate for:
• Practicing software engineers to learn component-oriented technologies and
programming
• Practicing software architects to get a concise view of various component-
oriented technologies available in Java along with hands-on examples
• Academic students studying software development for understanding the
benefits of component-oriented software development and assembly, for
learning the concepts, and for gaining hands-on programming knowledge in
various component models in Java
The book has a companion Web site (http://www.codabook.com) on which all the
source code used in the book are hosted. The source code for the CODA i mplementation
of the end-to-end case study presented in Chapter 11 using various Java c omponent
models are also hosted on the Web site. The Web site will also serve as a technical
forum for further discussions of the topic, and for any updates such as errata.
We would like to acknowledge and immensely thank Infosys Limited for sup-
porting and encouraging this book project. We would like to especially thank
S. Gopalakrishnan, our mentor, and Vice Chairman, Infosys Limited, for his constant
guidance, support, and encouragement during the execution of the project and for gen-
erating interest on this topic. We would like to thank Professor Nenad Medvidović,
Professor and Associate Chair for Ph.D. Affairs, Computer Science Department,
University of Southern California, for writing the Foreword.
We would like to thank Professor Y. Narahari, Chairman, Department of Computer
Science and Automation, Indian Institute of Science (IISc), Bangalore, for his v aluable
technical review input on the book. We also thank Ravindra Babu Tallamraju,
Principal Researcher, Infosys Limited, for helping with a detailed technical review
of the book. Special thanks are due to Srikantan (Tan) Moorthy, SVP, Group Head
of HR, former Global Head of Education and Research, and Nandita Gurjar, Global
Head of Education and Research, for their constant support and encouragement.
Our sincere thanks to our colleagues Soumya Bardhan, Shikhar Johari, Vishal
Vijay Verma, Rohit Jain, Vaasavi Lakshmi Jammalamadaka, Karthika K. Ravigopal
Nair, Vibhuti Mahendra Pithwa, and Navdeep Kumar, for their help in software
development, documentation, and testing of the companion code and the workbench
tool to demonstrate the concepts and principles. Special thanks are due to Soumya
Bardhan and Shikhar Johari for their contribution of creating all the figures used in
this book.
Special thanks are due to T.S. Mohan for his help. We would like to extend our
special thanks to Deepa Jagdish, John Wyzalek, Jessica Vakili, and Linda Leggio at
Taylor & Francis for their support throughout the project. Last but not the least, the
authors would like to acknowledge and thank their beloved families for their patience
during this project.
Trademark
All the registered trademarks used in this book are the properties of their respective
owners/companies. The authors have no rights to these trademarks. Example
organizations, products, domain names, e-mail addresses, logos, people, places, and
events depicted in this book are fictitious and no association with any real organiza-
tion, product, domain name, e-mail address, logo, person, place, or event is intended
or should be inferred.
The book has a companion Web site (http://www.codabook.com) on which all the
source code used in the book are hosted. The Web site will also serve as a technical
forum for further discussions of the topic, and for any updates such as errata.
Piram Manickam is an ardent technologist. During the past two decades he has
worked with many software development teams and built a number of systems
using various development platforms. He has a special interest in object-oriented
design. He has authored many technical articles. He has been practicing and teach-
ing component-oriented development and assembly (CODA) for the last few years.
He is a technical consultant and architect on many software component–based
projects at Infosys. He is a graduate of electronics and communication engineering
from Regional Engineering College (currently NIT) in Tiruchirapalli, India. He
is currently pursuing a master of science in computer engineering from the Illinois
Institute of Technology, Chicago.
S. V. Subrahmanya (also known as SVS) has more than 25 years of experience in the
information technology industry and academics. SVS is currently working at Infosys
Limited as vice president and is a research fellow at Infosys. He heads the E-Commerce
Research Labs. He is also responsible for competency development of employees
across the technical spectrum including new upcoming areas of technology at Infosys.
SVS has published many papers in reputed journals and international conferences.
He has coauthored books titled Discrete Structures, Web Services: An Introduction (Tata
McGraw-Hill, 2004), J2EE Architecture (Tata McGraw-Hill, 2005), and Enterprise
IT Architecture (Wiley India, 2006).
1.1 Introduction
When we compare the software industry with other mature industries, it seems to
be in its early stages of evolution. This is because other industries have advanced
to automated mass production capabilities from primeval practices of individual
craftsmanship-based production, and the majority of software is hand-built one line
at a time by individual craftsmen (programmers) even now. The component-based
software development paradigm is expected to help evolve the software industry
from micro-level line-by-line building practice to a macro-level mass production
practice.
Software products and services vendors are always under pressure to deliver bet-
ter-quality products at lower cost and shorter time frames. Most of the time the
software engineering team buckles under this pressure. What are the challenges
that software engineers face in achieving these goals, and how do they overcome the
challenges?
The biggest challenge is that the requirements for newer systems are getting more
complex than ever before, and software development techniques have not adapted
rapidly to the changing demands. Because of this, software developers are perenni-
ally looking forward to newer techniques that can bridge the gap between business
demands and state-of-the-art software development methodologies.
Divide and conquer is a time-tested technique to effectively manage a complex
problem. The technique involves breaking the larger problem into smaller, more
manageable problems. After the smaller solutions are obtained, they can be combined
to get the larger solution. CODA uses the divide and conquer technique to solve the
problem of complexity.
Component as a concept stems from two root concepts: composition and decomposition.
Composition is the act of assembling a system from individual parts. Decomposition
is the act of dismantling parts from a system. The parts participating in the acts of
composition and decomposition are known as the components of the system. Put
another way, a component is part of a whole (system) which it can be attached with or
detached from.
A common example of a component-based system is Lego®, in which building
blocks are assembled to a toy structure or dismantled. A more sophisticated example
could be an electronic product (e.g., a stereo system), which is assembled from basic
components such as resistors, transistors, and advanced components such as integrated
circuits (ICs).
Any product, be it software or otherwise, can be built in many different ways.
For example, a kitchen cabinet can be completely custom built from raw materials,
or it can be assembled from standard modular kitchen parts available from market,
or it can be built from a mix of modular kitchen parts and custom-made parts.
Similarly, software products can be completely custom built, or they can be built
by integrating off-the-shelf software products available from market, or they can
be built using a mix of both. The key difference between both of these examples
is that while modular kitchen parts can be assembled to arrive at the final product,
off-the-shelf s oftware products need to be integrated to arrive at the final product.
The reason for this d ifference is that the modular kitchen parts were designed
and manufactured to be compatible with one another, while the software products
were not.
Components are parts of a product that are meant to be assembled together. The
basic component principle is to design and build parts that are meant to work together
rather than work in isolation. Parts of a modular kitchen follow this principle, while
disparate software products do not. The result is easy assembly of kitchen c omponents
© 2010 Taylor & Francis Group, LLC
In t r o d u c ti o n t o C ODA 5
and tough integration of software products. Some software products that follow the
component design principle do exist. For example, Eclipse IDE is made of compo-
nents, and it is easy to acquire new plugin components for the IDE and literally plug
them to the core of the Eclipse product.
Apart from the basic characteristics of being part of a whole, components exhibit
many other characteristics pertaining to composition and decomposition operations.
We discuss the common characteristics of components in the next few subsections. We
describe these common characteristics of components with examples of nonsoftware
components. We use these characteristics later to extract an ideal candidate from
among a variety of common software constructs that could potentially play the role of
a software component.
The component framework provides a common fabric or environment over which the
components may be composed. For example, in electronic components, the printed
circuit board (PCB) serves as the fabric over which the electronic components can be
assembled; in mechanical components, the car skeleton or an equivalent m echanical
core structure serves as the framework over which mechanical components are
assembled.
© 2010 Taylor & Francis Group, LLC
6 C o m p o nen t- O rien t ed D e v el o p m en t a n d A s sem b ly
A component model defines what components are, how they can be constructed, how
they can be composed, and how they can be deployed. The component model also
defines the component framework. For example, a component model for electronics
components is defined by the Electronics Industries Alliance (EIA).
Each component specifies one or more interfaces through which other components
can be composed with it. The interfaces adhere to the composition standards defined
in the component model. For example, the interface of a nut is a hollow cylinder with
a threaded inner surface and a specified diameter. The interface of a bolt is a solid
cylinder with a threaded outer surface and a specified diameter.
Interfaces specified by a component are of two types. One type of interface is meant
for other components to compose with this component and make use of the function-
ality provided by this component. This type of interface is called a provided interface.
Another type of interface is meant for other components to compose with this compo-
nent and provide some functionality to this component. This type of interface is called
a required interface. A component’s interface specifications include both the provided
and required interfaces.
As an example for provided and required interfaces, consider the case of a nut and
bolt, which are to provide the functionality of fastening two mechanical components
together. The bolt provides a solid cylinder with a threaded outer surface as the interface
for composition. The nut provides a hollow cylinder with a threaded inner surface as the
interface for composition. If the diameters of the nut and bolt match, they can compose
together and fasten other mechanical parts.
Note that the nut’s provided interface (a hollow cylinder with threaded inner sur-
face) is the same as the bolt’s required interface, and the bolt’s provided interface
(a solid cylinder with threaded outer surface) is the same as the nut’s required interface.
Two components that coexist in a component ecosystem can be composed together only
if they are compatible with each other. Two components are said to be compatible if they
have complementing interfaces (i.e., the provided interface of one component should be
the same as the required interface of the other). For example, a nut of 2 cm diameter
cannot be fastened over a bolt of 3 cm diameter. Likewise, a nut cannot be fastened over
any nail irrespective of its diameter. If there is a nut and a bolt with an equal diameter
specification, then they have complementing interfaces, which makes them compatible.
© 2010 Taylor & Francis Group, LLC
In t r o d u c ti o n t o C ODA 7
During the composition process that composes components together, some of the
participating components may be actively performing the composition, whereas the
others may be passively participating in the composition process. For example, when a
gear and a shaft are being fastened by a nut and a bolt, the gear and the shaft are passive
participants of the fastening process, and the nut and the bolt are the active compo-
nents performing the fastening. Note that this notion of active and passive components
is limited to the composition process; it does not imply that the passive components
will continue to play a passive functional role in the resultant composite product. For
example, in the resultant gear assembly from the previous example, the shaft and gear
are active functional components during mechanical operations, even though they
were passive components during composition.
Early software systems developed in the 1950s used machine languages and assem-
bly languages that did not have any software components. With the introduction of
Fortran-I in the mid-1950s, software systems could be developed in a higher-level
programming language than assembly language. However, code reuse was still l imited
in Fortran-I.
© 2010 Taylor & Francis Group, LLC
8 C o m p o nen t- O rien t ed D e v el o p m en t a n d A s sem b ly
Fortran-I-based software systems developed in the 1950s could not use any
s oftware component, not even in the source code form for this reason. When Fortran
II was introduced in 1958, the concept of a subprogram was introduced. The subpro-
gram could be either a function or a subroutine. Subprograms are reused by many
main programs through function or subroutine invocations. Thus, Fortran II-based
software systems employed subprogram-based source code components. Fortran II
also provided support for independent compilation of a subprogram. Therefore, the
subprogram could be used as a static binary component as well.
In 1960, Algol-60 was released, which introduced the block structure concept.
The block structure allowed programmers to localize parts of programs with new
data environments or scopes. These code blocks could be reused across programs by
means of a rudimentary reuse process that copies blocks of code from one program to
another. Even though the code blocks are not scalable source code components, they
are an important concept in source code components.
In 1967, the Simula-67 programming language was born, and it brought with it the
concept of classes. At that time, the concept of data abstraction and abstract data type
did not exist, and the connection of Simula-67 classes to these concepts was not found
until 1972. Simula-67 also introduced inheritance.
Thus, class as a component in the object-oriented paradigm was born.
In 1971, the Pascal programming language was introduced. Pascal implementations
support separate compilation. Each unit includes both interface and implementation.
Interface of one compilation unit can be imported to another compilation unit with a uses
statement. This feature promoted static binary components in Pascal implementations.
In 1978, C was born. It promoted the reuse of function libraries as static binary
components. Header files served as interfaces between components.
Smalltalk, which was born in 1972, and reborn in 1980, treated everything as an
object, a concept that has been borrowed in modern-day programming languages.
The difference between a subprogram component and an object component is that the
subprogram is just a method call that does not maintain data, whereas an object main-
tains and encapsulates data apart from providing a method call form of interaction.
With the birth of C++ in 1984, and subsequently Java in the 1990s, and .NET in
2000, object-oriented programming and class libraries occupied the center stage of
components in the form of static binary components and dynamic binary components.
Distributed dynamic components became prevalent in the 1990s, with the introduc-
tion of Java Beans, CORBA, COM, DCOM, JEE, and other similar technologies.
See Figure 1.1 for a historical overview of software components.
Extending the definition of the generic component from Section 1.4, software compo-
nents are units of composition and decomposition in a software system. Composition
of an appropriate collection of software components should yield a complete software
© 2010 Taylor & Francis Group, LLC
In t r o d u c ti o n t o C ODA 9
Assembly-Language Aspect-Oriented
Programming Programming
When a collection of functions are packaged together, they form a function library.
Together these functions implement complex functionality. However, to access the
complex functionality, one need not invoke each of these functions. It is sufficient to
invoke certain entry point functions that in turn invoke other functions. The entry
point functions are known as an API (application programming interface) of the func-
tion library. The function library makes only the API functions visible from outside
the library and hides the complexity of other functions. When function libraries are
used as software components, one component composes with another component by
invoking the API functions exposed by the latter.
There are certain limitations associated with the use of function libraries as soft-
ware components. The API of a component can be invoked by another component
only through a common programming language. The composition of two compo-
nents happens from the source code of one component which invokes the API func-
tion call of the other component. Because the wiring between the two components
is hardcoded in the source code, the composition is not amenable to rewiring during
runtime. In addition to these limitations, function libraries tend to make use of global
variables, which obscure the exposed API and provides backdoor entry to internal
functions.
The consuming component is provided with the interface type object only during
runtime. In the source code, the consuming component refers to an object of interface
type, but the object is not instantiated until runtime. This breaks the hardwiring con-
straint associated with function library software components. Object library software
components can be easily rewired during runtime. We discuss this feature in detail in
the next chapter.
To facilitate reuse, we should be able to store and retrieve software components
from a repository. A function library or an object library can be stored in the form of
source code or binary code. A software component distributed as source code can get
modified before reuse, which is not encouraged. If a software component needs some
changes before it can be reused, these changes should be tracked, and the modified
component should be stored in the repository as a new component. So a software
component repository stores each component as a binary code in primary storage. A
secondary storage can store the component as source code, but this storage is restricted
to users with an obligation by them to submit a new derived component into the
repository. This is discussed in detail with examples in the next chapter. In the rest of
this book, we concentrate on software components made of object libraries and not of
function libraries. (See Figure 1.2.)
Source Code
Functions, Classes
Components
Static Binary
Function Libraries, Class Libraries
Components
Components are meant to work together. As discussed earlier, the interactions between
components happen only through interfaces. The component interface defines a set of
accessible operations. An interface can be considered as contract between two com-
ponents. One component offers the interface, and another component consumes the
interface. A component may offer and consume more than one interface.
An interface is merely a list of operations with their syntax and semantics and does
not specify any implementation. Because of this, a component in a component assem-
bly can be replaced with another component with different implementation, but which
offers the same interface. The replacing component can also provide a richer interface
than the original component. Such a replacement enriches the overall functional-
ity offered by the system. Through an iterative replacement of components by richer
components, gradual system evolution can be well managed.
Typically, an interface specification is only syntactic in which the signatures of
various operations of the interface are specified. A semantic specification needs to
specify the effect of invoking the operations on the interface. Such a specification also
requires a domain and data model that explains the semantics. A less formal semantic
specification can include the preconditions and postconditions associated with each
operation defined in the interface. Semantic specification provides a stronger contract
between the components than syntactic specifications.
It is important to notice that as components evolve and provide richer interfaces,
a versioning mechanism is required to track the differences between evolving interface
specifications. A providing component and a consuming component are unknown to
each other prior to assembly. The only common premise on which both operate is the
© 2010 Taylor & Francis Group, LLC
In t r o d u c ti o n t o C ODA 13
common interface specification. Hence, any mismatch between the providing and
requiring sides can result in catastrophic consequences during runtime.
In addition to the above, an interface specification can include global constraints
and invariants maintained across operation invocations. This can be useful in under-
standing the semantics of the component in conjunction with the preconditions and
postconditions associated with each operation. An interface specification serves as a
contract between the component providing the interface and the component consum-
ing the interface.
Apart from the functional specifications of an interface, it is important to consider
the quality attributes (extra-functional or nonfunctional attributes) of the component.
This can be specified by means of service level guarantees such as latency, reliability,
accuracy, availability, mean time between failures, mean time to repair, capacity, and
so forth.
Apart from the programming interface, a component can have a data interface and
a user interface. The data interface defines data structures used in the programming
interface specifications. The data interface also specifies persistence functionality
provided by the component. The user interface provides user interaction mechanisms.
also standardizes the mechanism by which one component can expose the interface
through a socket and another component can consume that interface using a plug.
This is called the composition standard specification in the component model.
Apart from the standardization of the composition mechanism among the
components and between the components and the common fabric, the compo-
nent model defines how a component must be packaged, stored, and distributed.
Typically, the component model is supported by a runtime component framework
onto which components are deployed. The component framework serves as the fab-
ric containing sockets onto which the deployed components plugin. Examples of
component models are EJB, .NET, CORBA, Spring, SCA, and OSGi. These com-
ponent models define a component framework, structure of the component that can
be deployed onto the framework, and a composition mechanism between the com-
ponents. Some of the component models also define a mechanism using components
which can publish their provided interfaces. Other components can search for an
interface that they require. Some component models also define an auto discovery
mechanism, in which the framework performs the lookup on behalf of the requiring
component. More details about the component model and frameworks are discussed
in Chapter 3.
1.8.1 Requirements
During this phase, the requirements of the system as a whole are captured and the
requirements’ specifications are created.
During this phase, the requirements are analyzed and the architect in consultation
with the existing software assets repository identifies architectural elements of the
system. From the architectural specification, individual component specification is
derived. Many of these identified components may already have specifications as
part of the existing asset repository. Component architecture and component design
documents are the artifacts created during this phase. The component model to be
used for the system is also identified during this phase.
Many of the components may be sourced from the existing asset repository. Those
components that are not readily available are created and developed during this phase
as per the component specifications. Typically, components are developed according
to a standard component model chosen during the architectural phase. The end result
would be the source code and binary code representation of the components created.
The newly developed components and existing components are assembled to create
the software application. The assembly of the components is done with the help of a
component framework that supports the identified component model.
1.8.5 Testing
Integration and system testing are carried out to validate that the system meets all
of the requirements’ specifications. System test cases and integration test cases are
created. The system is tested against the test cases. If required, the components and
the system will go through a defect fixing phase.
1.8.6 Deployment
The assembled components are packaged as per the packaging mechanism specified
by the component model. For example, Java-based components are packaged in JAR
files. The packaged components are deployed in the environment that supports the
component framework.
There are several artifacts involved during the component development and deploy-
ment cycle, and they are graphically represented in Figure 1.4. The business execu-
tive defines the functionality of the system, which is captured as a business domain
© 2010 Taylor & Francis Group, LLC
16 C o m p o nen t- O rien t ed D e v el o p m en t a n d A s sem b ly
Business Component
Business Domain Model Specifications
Vision
Use Case Component
Model Architectures
Component
Design Doc
Tester
Tested
Application
Component Component
Assembler Developer
Deployer Assembled
Application Components
Deployed
Application
model and use case model by the business analyst. The system architect who is spe-
cialized in component engineering creates component specifications from the busi-
ness domain model and the use case model. The architect is responsible for creating
component architecture and the design document by referring to the existing software
asset repository. At the end of this activity, the architect would have identified exist-
ing components and the components to be built. The design document is handed over
to the component developer who develops the component adhering to the specifica-
tion using a standard component model identified by the architect. The assembler
assembles the software application with the existing components and the newly built
components. The tester tests the components as per the test cases, and the deployer is
responsible for deploying the assembled and packaged application to the deployment
environment supporting the component framework.
Traditional software engineering works on the premise that requirements for a s ystem
are completely specified before the system is designed and built. In practicality, the
requirements always evolve over time. Component-based system engineering is fully
aligned to this evolving requirements scenario. A component assembled into the
system under construction can be replaced by another component without affecting
the rest of the system. This provides an efficient and controlled system evolution path,
in which one can enrich the functionalities of individual components and replace
them to gradually evolve the system.
© 2010 Taylor & Francis Group, LLC
In t r o d u c ti o n t o C ODA 17
Components also aid in faster system build turnaround time because the system is built
from available components. In case some of the required components are not available,
parallel development of the required components can reduce cycle time. Components
are used in multiple contexts in different products. Hence, they become less error prone
and more rugged as they get widely deployed in many products over a period of time.
There are many other advantages in using components to build software. These
advantages are summarized below:
• Increased productivity
• Contained complexity
• Reduced cycle time
• Improved quality
• Parallel and distributed development teams
• Reduced maintenance cost
There are many advantages to building a system from components than otherwise
(for instance, as a monolith). Software product firms such as Microsoft®, Oracle®, or
IBM® can reuse software components designed and developed as part of one p roduct
in another product, either as is or with variations to the original. If we consider c ustom
software development firms such as Infosys® or Accenture®, each software system
made by them is custom made for the clients. These firms can reuse software compo-
nents designed and developed as part of one custom software system in other software
systems, reducing effort and increasing quality as we elaborate below.
1.9.1 Reusability
Evolution is the longest and most expensive phase of the software product life cycle.
Component-based software systems are more open to evolution, as the composition
of the system can go through gradual changes over a course of time without a big
bang effect on the overall system. In other words, when a first wave of evolution
happens on a software system, a set of constituent components may get exchanged
with a newer set of components that cater to the requirements of evolution. The overall
system is not affected during this exchange of components. After some time, when
a second wave of evolution happens, another set of components may get exchanged
with newer c omponents, and so on. Thus, at the end of some Nth evolution wave, the
software system may have a completely new set of components compared with the
original composition structure it had before the first evolution wave. Such a smooth
and g radual e volution is not easily achieved in a monolith system.
The more a component is reused, the more defects would get exposed. Thus, with
appropriate central defect fixes and propagation of fixes to all systems, the overall
quality of software systems would improve.
Reusable components can provide an effective basis for quickly building a proto-
type of a software system. This provides an opportunity to present mock systems
during bidding, or to get feedback from the stakeholders during the early stages of
development.
© 2010 Taylor & Francis Group, LLC
In t r o d u c ti o n t o C ODA 19
1.10 Summary
Review Questions
2.1 Introduction
The Java platform, Standard Edition (Java SE) consists of the following elements:
• Java Programming Language
• Java Software Development Kit (JDK)
• Java SE Application Programming Interface (API)
• Java Runtime Environment (JRE)
As application developers, we write object-oriented programs using Java classes. The
Java classes that we define can refer to other Java classes within the application’s code.
In addition, the Java classes can refer to classes external to our application’s code after
certain configurations are carried out. For example, we refer to Java SE API to invoke
prebuilt platform provided features. When we invoke any class defined in the Java
SE API, we are referring to classes external to our application’s code. Where does
this external code come from? The Java SE API specifications are implemented and
packaged inside the JRE runtime library called rt.jar.* We get visibility and access
to this external code from within our source code by including the rt.jar file in the
build path (during development time) and in the class path (during runtime). As an
example consider the application source code shown below:
package codabook.helloworld;
public class HelloWorld {
public static void main(String[] args) {
* rt.jar is the file name in Microsoft Windows platforms; in MacOS the file name is classes.jar.
System.out.println("Hello");
}
}
In this example, we defined a HelloWorld Java class inside a Java package coda-
book.helloworld. The class refers to the System class which is part of another
Java package java.lang. The System class is not part of our application, but it is
part of the rt.jar file that is included in our build path. Usually, to refer to classes
outside of the Java package that the source code belongs to, we need to refer to the
external class with a fully qualified name such as java.lang.System or we need
to import the class using an import statement like import java.lang.System,
after which we can use the simple class name such as System across our source
code. We did not have to do it in this example because all the classes in java.lang
are imported implicitly by the Java compiler. Consider another example whose
source code is shown below:
package codabook.greeting;
import java.util.Scanner;
public class Greeting {
public static void main(String[] args) {
System.out.println("Hello, What is your name?");
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
System.out.println("Greetings, " + name + "!");
}
}
package codabook.greeting;
public class Greeting {
public static void main(String[] args) {
System.out.println("Hello, What is your name?");
java.util.Scanner scanner =
new java.util.Scanner(System.in);
String name = scanner.nextLine();
System.out.println("Greetings, " + name + "!");
}
}
In all the example programs we presented, the rt.jar file has packaged reusable Java
classes. Similar to the rt.jar file, a developer can package custom code into a JAR
file for distribution and use with other applications. Thus, JAR files provide a good
mechanism for storing and distributing physical software components in Java.
While the JAR file provides a physical component boundary, the Java package
construct provides a logical component boundary across components. For example,
the rt.jar file includes many packages such as java.lang, java.util, and so
forth. This helps the same physical component to carry multiple logical components.
There is an additional advantage in using packages as a logical boundary for compo-
nents. It helps us to reuse simple class names across multiple components. For example,
we had used the Scanner class in the example programs presented so far. This class
was provided by the physical component rt.jar and the logical component java.
util package. Suppose we had to define another Scanner class as part of another
software component, say, a credit card processing component. If this new component
has a logical boundary different from java.util, say, codabook.creditcard,
the two Scanner classes have unique fully qualified names though they share a
common simple name. In the next section, we show how to build software compo-
nents using the package as a logical boundary and the JAR file as a physical boundary.
Any Java code implementing a piece of functionality can be turned into a component
by defining logical and physical component boundaries around it. For example, con-
sider a Java class that calculates the age of a person given her date of birth. The source
code of the AgeCalculator class is given below:
package codabook.agecalculator01;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class AgeCalculator {
public int calculateAge(Calendar dateOfBirth) {
if (isCurrentYearBdayPassed)
age = currentYear - birthYear;
else
age = currentYear - 1 - birthYear;
return age;
}
}
this package into the AgeCalculator01.jar file. Any developer who needs age
calculation logic as part of an application that is being developed can reuse the age
calculator component, by including the AgeCalculator01.jar file in the build
path and importing the codabook.agecalculator01.AgeCalculator class
into the source code. Let us build one such application. The application would collect
the date of birth details from the user, make use of the age calculator component to
calculate the age, and display the age back to the user. The application’s source code
is shown below:
package codabook.agecalculator01.app;
import java.util.*;
import codabook.agecalculator01.AgeCalculator;
public class AgeCalculatorApp {
public static void main(String[] args) {
AgeCalculator a
geCalculator =
new AgeCalculator();
int age
= ageCalculator.
calculateAge(dateOfBirth);
System.out.println("Your age is" + age);
}
}
The age calculator application makes use of the age calculator component as boldfaced
in the source code. This is made possible by including AgeCalculator01.jar in
the build path during the build time and in the class path during runtime. The build
time and runtime dependency are illustrated in Figure 2.1. The outer box signifies the
physical component boundary, and the inner package box signifies the logical compo-
nent boundary. Internals of the components are housed within the logical boundary.
The simple JAR and package-based components worked well in the creation of the
age calculator application. However, there is one drawback in this schema. In compo-
nent-oriented development and assembly, we want to source components from indepen-
dent third-party vendors. This means the vendors and the components that they develop
AgeCalculator01.jar AgeCalculatorApp01.jar
codabook.agecalculator01 codabook.agecalculator01.app
+ AgeCalculator + AgeCalculatorApp
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookultra.com