Академический Документы
Профессиональный Документы
Культура Документы
Ben Fairfax
Thursday 21st September 2006
Preface
• Making Components - Efficient and robust development procedure for the creation
of multi-platform Component Packages.
Please note that all the Client Examples, Example Component Packages and associated
Build system source files can be downloaded from the directory:
http://www.webcabcomponents.com/iom/development/examples/
If you have any feedback or queries regarding this guide this please feel free to contact
us via email or on-line at:
support@WebCabComponents.com
http://www.webcabcomponents.com/support/
i
Synopsis
0.1 Details
Title: Component-based Development
Speaker: Dr Ben Fairfax
Organizer: British Computre Society (BCS) Isle of Man Branch
Time: 6:30pm (6pm Doors Open), Thursday 21st September 2006
Location: Shearwater Suite, Hilton Hotel, Douglas, Isle of Man
0.2 Overview
A Software Component (i.e. DLL or JAR) is a piece of technical or business functionality
embedded within a self-contained software artifact which can be re-used across an organ-
isation or industry. The value of Software Components is that they enable the re-use of
software which leads to significant reductions in the cost, time and expertise required in
order to undertake a given software development project.
Topics Covered
• Using Components: How to use a Component within the three generic types of
client application?
• Making Components: How can an existing development team most efficiently start
creating re-usable software component packages? Here we will detail many aspects
of our internal development process and build systems which have been refined over
a number of years which enable a team to efficiently create multi-platform software
component packages.
ii
Synopsis Chapter 0
iii
Contents
Preface i
Synopsis ii
0.1 Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
0.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
0.3 About the Speaker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
0.4 Web Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
I Introduction 1
1 What is Component-Based Development (CBD)? 2
1.1 Items of Slide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Description of Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.1 Enable Software Re-use . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.2 Build Software by assembling blocks . . . . . . . . . . . . . . . . . 3
1.2.3 Why bother? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Examples of Formal Definitions . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3.1 Dr Szyperski . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
iv
CONTENTS CONTENTS
v
CONTENTS CONTENTS
IV Making Components 41
14 Build Strategies 42
14.1 Items of Slide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
14.2 Description of Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
14.2.1 Consider Complete Life cycle . . . . . . . . . . . . . . . . . . . . . 42
14.2.2 Separate IT, Business Aspects . . . . . . . . . . . . . . . . . . . . . 42
14.2.3 Multi-platform Approach . . . . . . . . . . . . . . . . . . . . . . . . 43
14.2.4 Automate as much as possible . . . . . . . . . . . . . . . . . . . . . 44
vi
CONTENTS CONTENTS
vii
Part I
Introduction
1
Chapter 1
What is Component-Based
Development (CBD)?
2
What is Component-Based Development (CBD)? Chapter 1
• CBD - Elicits requirements from the user, selects an appropriate architectural plat-
form and style to meet the objectives of the system to be built, and then:
Often not all the functionality required will exit within pre-existing components and
hence custom components will need to be developed to address those aspects of the
system that cannot be implemented using existing systems.
• High Quality: CBSE encourages the use of standard software infrastructure (.NET
IIS Stack, J2EE App Server, Tomcat/Spring, Excel) and predictable architectural
patterns thereby leading to a higher quality result.
• Lower Knowledge Barrier: By hiding the discrete parts and only exposing well
defined interfaces, the user only need to know what functionality is required, not how
that functionality is constructed. The remark means that the programmer does not
need to know the nature of an algorithm, and a business user does not need to know
the details the technology infrastructure.
3
What is Component-Based Development (CBD)? Chapter 1
4
Chapter 2
Here we detail the motivation and historical context of CBD from the point of view of:
• Business User - Primary focus is not software development but applying specific
business intelligence (i.e. quantitative analyst, accounting etc).
5
Historical Context and Motivation for CBD? Chapter 2
composing software from its base ingredient of source code. This contrasts completely from
other domains of engineering such as construction where the development of a house for
example consists solely of the assembling of pre-build components (bricks, tiles etc).
The reason why a housing builder uses pre-made components is that its significantly
cheaper, easier and agrees with the industry wide standards within the construction in-
dustry. The Components themselves are commodities and do not lead to competitive
differentiation of one house builder over another. A similar situation holds for all other
domains of engineering including software and within all of them there is no added value
created by ‘re-inventing the wheel’.
The re-use of Business Intelligence distributed in text format needs to be completely un-
derstood and repackaged before the principles, ideas and techniques contained therein can
be re-used within other domains. This is an inherently inefficient approach. CBD plays
the role of presenting the Business Intelligence in a format (i.e. software, documentation
and examples) which is easier and more efficient to re-use within other domains by a wide
range of potential users.
Within the quantitative fields this has been particularly apparent. Where at present
any Math or Physics PhD are in a situation where they must learn at least something
about programming in order to undertake potential careers in finance, corporate research
departments or software companies.
6
Chapter 3
7
What is a (Business) Component? Chapter 3
• Well defined Interfaces - The interfaces are the only means by which the function-
ality of the component can be accessed. Therefore the interfaces must be compre-
hensive in terms of accessing functionality, clearly documented and ideally intuitive.
• Composition - Since a component does not run in the sense of a standard application
(for example, console application) there most to a robust mechanism of composition.
8
Chapter 4
• Costs and Advantages of making Packages: Higher cost, Higher Re-use, Higher
Asset Protection.
• API documentation: Details the nature of the functionality offered, the signatures
including returned data type of all methods, interdependence of the methods.
9
What are (Business) Component Packages? Chapter 4
10
What are (Business) Component Packages? Chapter 4
In order to ensure the long term sustainability of a wide scale Component Development
initiative within an organization it is necessary that the development team or department
who invest resources in the development of component packages receive credit (monetary,
business recognition etc) for this investment of time and effort.
11
Chapter 5
A central part of the value of components is that they can hide the innate complexity of
the business intelligence and/or IT technologies to the users of the Component.
• Hide Business Complexity: Only need to know what I need, not how it is done.
12
Empowering Users, Developers and Organizations Chapter 5
As we will see by later the use of a ‘Component Production System’ (ie build system)
you are able to produce a range of software implementations from a relatively few software
artifacts. Hence, maximizing the potential user base while also allowing those which the
skills to take advantages of more powerful software development platforms.
• Pre-made examples: By providing the user with pre-made examples client appli-
cations which run out-of-the-box it can even be the case that in order to adopt and
use the Components functionality via the pre-made Clients the user does not need
to know apriori how the write such a client.
We illustrate this point later when we demonstrate Client applications using a Curve
Fitting Component.
Within a development team this serves the important role of clearly defining responsi-
bilities, and allowing each development team to solely concentrate on understand and
implementing its set of functionality and saving them the need to know details concerning
other parts sections of the development.
13
Part II
14
Chapter 6
15
Types of Component Platforms Chapter 6
tionality from each system. For new development, Microsoft recommends .NET as a pre-
ferred technology because of its powerful managed runtime environment and services.
Links:
A Software Components is offered as a tool extension or add-in in the case of Excel. The
notion of a tool extension or add-in is essentially universal across all development tools
where each tool has its own extension integration API. By far the most popular tool in use
by Business Users and programmers for quantitative modeling and analysis is Microsoft’s
Excel which support a tightly integrated add-in development framework.
Declarative Approach
Since the software is managed by a container it allows aspects such as data source, caching
framework and other technology Aspects to be assigned via meta data files by the container.
For example, in the case of J2EE Application service the EJB Component contains a
deployment descriptor which is an Application server specific XML compliant meta data
file which describes the nature of the Component and the services which are to be provide
by the Container to the component during run-time.
16
Types of Component Platforms Chapter 6
6.2.4 Vendors
Both the Java and .NET platforms are supported by the major developers and it is expected
that the relative use of these platforms will be roughly 50/50.
17
Chapter 7
Though it is possible to use state and user define types on the Office Excel and XML Web
service platforms the developer expectations and ethos does not encourage this.
• Limited Support of State: Excel can support state, Web service can use of cookies.
18
Excel and XML Web service Platforms Chapter 7
• Make a call to a ‘set’ method within the Excel environment, which to parsed to a
.NET call via the Interop API which assigns given private fields within an instance
of the .NET Component.
• When this occurs in order to preserve the state there is a call to the instance of the
Workbook from the Component which creates another hidden worksheet within the
workbook and writes the private fields to the workbook on line 1.
• The user of Excel calls another method from the Stateful service which first checks
the values of the private fields within the hidden workbook, set these values within
the .NET Components and calls desired method and so on.
Remark: These feature has not been implemented by ourselves and as far as I know
no one else has done this.
Please note that WebCab XL (Community Edition) is freely available from the location:
http://www.webcabcomponents.com/office/
19
Excel and XML Web service Platforms Chapter 7
20
Excel and XML Web service Platforms Chapter 7
21
Chapter 8
The .NET and J2SE platforms are essentially the same in terms of functionality capacity
and many of the technologies which exist on one platform can a corresponding technology
on the other.
• User Session Management: Client user sessions are not uniquely managed (Ex.
.NET and SQL 2005)
A good examples of this limitation is illustrated with the limitation that a .NET v2.0 com-
pliant components can be deployed to SQL Server 2005, however they are not considered
SAFE unless they only used static fields which are read only or constants. In particular,
22
.NET and the J2SE Platform Chapter 8
SQL Server 2005 will run the component in-process and potentially share classes/assemblies
between users, and so for safety needs to be strict with statics. So that there is not an
unpredictable communication route between concurrent activities all static fields will need
to be read only or constant.
The reason for the seemingly annoying limitation is precisely for of the last of management
of user sessions and the fact the component is not replication for each user session (please
note I am referring to replication of the business layer logic, that is, the component, not
the data management system).
You are able to deploy the components as an ‘unsafe assembly’ which may contain static
fields by using the UNSAFE attribute. That is, to deploy you input prompt:
23
.NET and the J2SE Platform Chapter 8
24
.NET and the J2SE Platform Chapter 8
25
Chapter 9
• Complexity and Cost: Developers can be hard to find and can be expensive.
26
J2EE Platform and EJBs Chapter 9
27
Part III
Using Components
28
Chapter 10
The internet has a huge effect on the software industry, the discovery and application of
business intelligence and the ecosystem of software service providers and vendors.
The internet offers an unparralleled informatoin resource for the discovery and realisa-
tion of the need to use various Business Intelligence and technology aspects. Now almost
all information workers can Goggle! a topic and get details accurate information in real
time. This evolution has meant that for example sophisicated quantitative techniques have
become more widely used by the non-specialist.
To sum up the internet not only allows the distribution of Software Components but
29
The Internet changed everything Chapter 10
also the discovery and distribution of information (of third party information) concerning
the functionality contained within such Software Components.
Components are typically not mass market products and therefore the ability to easily
obtain global reach makes the development of specialised Component Packages commer-
cially viable. Moreover, easily obtaining global reach means a larger user base resulting in
the development costs being spread over the larger base and hence enhancing the value of
the software component ecosystem.
30
Chapter 11
As mentioned before a Component can only be used from a Client application (since Com-
ponents do not run). Moreover, we have found that for a Business Component (collection
of Business logic, or Black-Box) there are only three types of generic client application
because there are only three generic types of Business Components, namely:
• Stateless Bean/Component/Service
• Statefull Bean/Component/Service
This may seem rather technical but I assure you that the realisation of these three types
of generic types of components client application really are very straight forward in there
application. In order, to demonstrate how straight forward it is we will code and run
examples of these three generic types of client application.
31
Chapter 12
Here we demonstrate the three generic client types corresponds to three Business Services
of the three generic Types (stateless, statefull, statefull with helper types). The source
code for these examples with the associted Component DLL can be download from:
http://www.webcabcomponents.com/iom/development/examples/SumClients.zip
In order to run the examples download the zip file onto a Windows machine which has the
.NET Runtime installed, unzip the file, then run the Compile.bat and then Run.bat scripts
contains within one of the three subdirectories associated with each of the client examples
provided below.
• Download: http://www.webcabcomponents.com/iom/development/examples/SumClients.zip
using WebCab.Libraries.Cbd.BusinessLogic;
32
Three Generic Clients of Sum Component Chapter 12
// Instantiate Component
SumStateless instanceOfSumStateless = new SumStateless();
using WebCab.Libraries.Cbd.BusinessLogic;
// Instantiate Component
SumStateful instanceOfSumStateful = new SumStateful();
33
Three Generic Clients of Sum Component Chapter 12
using WebCab.Libraries.Cbd.BusinessLogicHelper;
// Instantiate Component.
SumWithHelperType instanceOfSumWithHelperType = new SumWithHelperType();
34
Chapter 13
Here we demonstrate the three generic clients in a more non-trivial setting to illustrate
again the three generic types of components and the associated client applications. The
source code for these examples with the associted Component DLL can be download from:
http://www.webcabcomponents.com/iom/development/examples/CurveFittingExamples.zip
In order to run the examples download the zip file onto a Windows machine which has the
.NET Runtime installed, unzip the file, then run the Compile.bat and then Run.bat scripts
contains within one of the three subdirectories associated with each of the client examples
provided below.
35
Three Generic Clients of Curve Fitting Components Chapter 13
//
// Here we construct the regression line of Y on X.
//
double[] regressionX1 = instanceOfCorrelation.LeastSquaresRegressionLineY(
new double[] {2.0,5.0,1.0,3.0,4.0,1.0,5.0,3.0,4.0,2.0}, // xValues
new double[] {50.0,57.0,41.0,54.0,54.0,38.0,63.0,48.0,59.0,46.0} // yValues
);
//
36
Three Generic Clients of Curve Fitting Components Chapter 13
37
Three Generic Clients of Curve Fitting Components Chapter 13
/// <summary>
/// Here we provide an implementation of the interface NonLinearFunctionBasis
/// for the function:
///
/// <p><code>y = f(x, a[0],a[1],a[2]) = a[0].Sin(a[1].x) + a[2].x</code></p>
/// </summary>
public class NonLinearSinus : NonLinearFunctionBasis {
//
// The default constructor of the class NonLinearFuncs.
//
public NonLinearSinus(){
}
/// <summary>
/// The implementation of the non-linear function:
///
/// <p><code>y = f(x, a[0],a[1],a[2]) = a[0].Sin(a[1].x) + a[2].x</code></p>
///
/// <p>which represents a non-linear regression model with model parameters
/// <code>a[0], a[1], a[2]</code> and a real variable <code>x</code>.
/// Therefore, the differential with respect the a[0], a[1] and a[2] is:</p>
///
/// <p><ol>
/// <li> <code>df/da[0] = Sin(a[1].x)</code>
/// <li> <code>df/da[1] = a[0].x.Cos(a[1].x)</code>
/// <li> <code>df/da[2] = x</code>
/// </ol></p>
/// </summary>
/// <param> evaluationPoint the point at which the function is evaluated.</par
/// <param> modelParameters a double array containing the values of the variab
/// coefficients.</param>
///
public double[] getValueAt (double evaluationPoint, double[] modelParameters)
// df/da[0] = Sin(a[1].x)
//
afunc[0] = System.Math.Sin(modelParameters[1]*evaluationPoint);
38
Three Generic Clients of Curve Fitting Components Chapter 13
// df/da[1] = a[0].x.Cos(a[1].x)
//
afunc[1] = modelParameters[0]*evaluationPoint
*System.Math.Cos(modelParameters[1]*evaluationPoint);
// df/da[2] = x
//
afunc[2] = evaluationPoint;
return afunc;
}
}
39
Three Generic Clients of Curve Fitting Components Chapter 13
40
Part IV
Making Components
41
Chapter 14
Build Strategies
Here we detail general principles which we have adhered to in the development of our
Component Package build process. In order to illustrate the ideas within the Component
Package Build System we will extend on the Sum Components examples we considered
within the previous section and consider a ‘Sum Component Package’. Please note that
all the sources and builds of the Final Component Packages can be downlaoded from the
directory:
42
Build Strategies Chapter 14
The point illustrated within the diagram is that if one new Business Intelligence Module
and one new technology aspect is included representing 50 percent additional development
time, then the build system as a whole will generate 9 software Component Artifacts rather
than 4, representing an increase of 125 percent in the output.
43
Build Strategies Chapter 14
Long
Decimal
Remark: We cannot see how Long[], Long[][], Decimal[], Decimal[][] types can be mapped
to VB.
44
Chapter 15
Though the build system itself consists of 10,000s of lines of intricate code, the application
of the build system significantly increases the efficiency with which a Component Based
Development process can be adopted within an organization.
Below I list three key ideas within the over-all design of our build system. By applying
these three principles through the build system you are able to gain from re-use of doc-
umentation and code throughout the multi-platforms software packages and Component
archive.
45
Chapter 16
The ’Super Docs’ are just a mark-up of the API documentation which is not specific to
any Component platform. The Super Docs are also the location where additional ’tags’
(or meta date) can be included:
• SumStateful Super Docs - Mapped to JavaDocs, .NET API, COM/Delphi API, .NET
Web service API, EJB API, JSP/ASP.NET Clients.
Yet, because there is only one interface for every business class1 , this interface is used
to generate the API Reference for both Java, .NET and all other platforms. This basically
means that the JavaDocs method and constructor comments should focus as much as pos-
sible on the business functionality and leave out technical details.
For example, when referring to a business class, you will not say ‘class”, or ‘bean”, but use
the ‘:service:” tag which will be accordingly replaced by the .NET and Java scripts.
1
There are two interfaces for Stateful Business Classes: one for methods and another one for construc-
tors.
46
Notion of ‘Super Docs’ Chapter 16
/**
* Stateless :service: which offers functionality for adding two real numbers.
*
* @excelClassName Sum
* @excelDescription Functionality for adding two real numbers.
*/
public interface SumStateless{
/**
* Evaluates the sum of two real numbers.
*
* @param a a double which is the first element of the sum.
* @param b a double which is the second element of the sum.
*
* @return the sum of two real numbers.
*/
public double sum(double a, double b);
16.2.3 SumStateful
package WebCab.Cbd.BusinessLogic;
/**
* Stateful :service: which offers functionality for adding two real numbers.
*
*/
public interface SumStateful{
/**
* Sets the value of the private field A, which holds a double.
*
* @param a is the first argument of the sum.
*/
void setA(double a);
/**
* Sets the value of the private field B, which holds a double.
47
Notion of ‘Super Docs’ Chapter 16
* arithmetic operation.
*
* @param b is the second argument of the sum.
*/
void setB(double b);
/**
* Returns the sum of the two private field A and B, which have been set using
* {@link #setA setA} and {@link #setA setA}.
*
* @return A double representing the sum of the two numbers.
*
* @throws Exception if one of the number had not been set.
*/
public double getSum() throws Exception;
}
48
Chapter 17
17.2.2 SumStatefulClient.xml
<overview>Client example of (stateful) SumStateful Component.</overview>
49
Multi Platform QA Client System Chapter 17
50
Chapter 18
• Platform Packaging: .NET XML Web services for IIS, EARs for J2EE App
Servers, WARs for Tomcat.
51
Chapter 19
Here we details the packages structure of the CBD Example package for the .NET Plat-
form. The full CBD Example Package can be downloaed in source code and binary form
from the locations:
• \XML Web services - .NET Web service DLL with ASMX proxies, QA Clients in
C#/VB.NET, HTML and CHM API Documentation.
52
Chapter 20
Here we details the packages structure of the CBD Example package for the J2SE Plat-
form. The full CBD Example Package can be downloaed in source code and binary form
from the locations:
53
Chapter 21
Here for convenience we summaries the source files which are required by our build system
in order to create our CBD Build System example. So far only one of these types of files
namely the source code implementation files which we have not provided an example for
which we now provide below.
• QA Clients XML Markup - XML file describing the structure of the clients.
• PDF Super Docs - Describing Business Aspects of the Component used in PDF/Web
site.
http://www.webcabcomponents.com/iom/development/examples/CBD BuildSources.zip
54
Build System Input Files Chapter 21
public SumStateless() {
}
using System;
public SumStateful() {
}
private double a, b;
private bool beenSetA = false, beenSetB = false;
return this.a+this.b;
}
}
}
55
Build System Input Files Chapter 21
public SumWithHelperType() {
}
/*
* Function stuff.
*/
private Function f = null;
56
Build System Input Files Chapter 21
\subsection {Details}
Within this :product: we have implemented the following functionality:
\begin{itemize}
\item {\bf CBD Module}
\begin{itemize}
\item {\bf Sum} - The arithemtic sum of two real numbers.
\end{itemize}
\end{itemize}
\input{FromTemplate/features.tex}
\input{FromTemplate/packagedetails.tex}
57