Title: Software Component Technologies:
1- Software Component Technologies
- Introduction
2What Are Components?
- A consistent part.
- - Macquarie Dictionary 1985
- An identifiable part of the whole
- Components are possibly
- Replaceable
- Interchangeable
- A means of supplying variation
- They are only a part, not the whole
3What Are Components?
- Examples of components
- Light bulb
- Lego blocks
- Hard disk
- 35 mm Film
- All of these are replaceable but which of these
are interchangeable that is, which provides
variation?
4Why Use Components?
- Components simplify the process of building
systems - Promote reuse of both design and implementation
- Allow specialization
- Camera manufacturers need not also make films
- Can the ideas of components be successfully
applied to developing software?
5What Are Software Components?
- Software components are binary units of
independent production, acquisition and
deployment that interact to form a functioning
system. - - Szyperski, C., Component Software
Addison-Wesley, 1998
6What Are Software Components?
- A software component is a unit of composition
with contractually specified interfaces and
explicit context dependencies only. - Context Dependencies
- Required interfaces
- Execution platform
- - Szyperski, C., Component Software
Addison-Wesley, 1998
7What Are Software Components?
- A component is a physical and replaceable part
of a system that conforms to and provides the
realization of a set of interfaces. - - Jacobson, J., Booch, G., Rumbaugh, J., The
Unified Software Development Process
Addison-Wesley, 1999
8Interfaces
- A surface regarded as the common boundary to two
bodies or spaces. - - Macquarie Dictionary 1985
- An interface is a point of contact
- Interfaces are contracts with rights and
obligations for both sides
9What Are Interfaces?
- Hard disk
- IDE, SCSI
- Electrical PowerPoint
- TV, Radio, Laptop, Light, Microwave
- Variations exist
- USA, Australian, British
10What Are Software Interfaces?
- Abstraction of a service that only defines the
operations supported by that service (publicly
accessible variables, procedures or methods) but
not their implementation. - - Szyperski, C., Component Software
Addison-Wesley, 1998
11What Are Interfaces?
- Interfaces are often described using an Interface
Definition Language (IDL) - IDLs are programming-language independent
- Which is more important, the component or its
interface?
12What Is Component Based Development
- CBD is the creation and deployment of
software-intensive systems assembled from
components, as well as the development and
harvesting of such components. - - Jacobson, J., Booch, G., Rumbaugh, J., The
Unified Software Development Process
Addison-Wesley, 1999
13Software Component Technologies
- Microsofts Component Object Model (COM)
- Suns Enterprise Java Beans
- CORBA and CORBAs Components
- EJB is a compliant implementation
- Microsofts .NET Framework
14Issues Involved in CBD
- Issues can occur because of
- Differing machine architectures
- Word sizes
- Programming languages
- OO, Functional, Imperative
- Operating systems
- Different instruction sets
15Solutions
- Common Type System
- Standardized types and user defined types
- Metadata Information
- IDL files
- Reflection
- Common Execution Semantics
- Cross language method invocation, COM and CORBA
- Virtual Machines
16Common Type System
- What is an integer?
- C/C Sequence of bits
- SmallTalk A class
- Java Both (int/integer)
- IDLs normally define an integer type which is
mapped into specific programming languages - Some languages define a standard size across
machine boundaries
17Metadata Information
- Sharing binary components requires that
developers can inspect components to find
information about their functionality. - Two methods are normally used to describe
metadata - IDL files (COM/CORBA)
- Reflection (SmallTalk/Java/.NET)
- However, Reflection is normally not used across
language boundaries.
18Execution Semantics
- Need to abstract about elements of execution,
such as - Calling semantics
- Object Models
- Data Access
19Execution Semantics
- Method call level
- COM/CORBA
- Object models
- Interface based, COM/CORBA
- Full-language semantics
- SmallTalk, Java, .NET (but this is often language
specific)
20What Are Interfaces?
- If interfaces are the publicly exposed methods
that a client can call on a server, how do
clients obtain the specification of these
interfaces?
21Accessing Information About Interfaces
- Component architectures generally use one of two
methods to provide information about interfaces - An abstract Interface Definition Language
- Which is a separate file to the definition of the
component implementing the interface - Is common in multi-language systems
- The interface may be defined by the actual
definition of the component
22What Are IDLs?
- Used to define an interface according to a
certain model (usually an object model) in a
programming language-neutral form. - - Szyperski, C.,Component Software
Addison-Wesley, 1998 - IDLs specify contracts
23What Are Contracts?
- Specification attached to an interface that
mutually binds the clients and providers
(implementers) of that interface. Contracts can
cover functional and non-functional aspects. - - Szyperski, C.,Component Software
Addison-Wesley, 1998 - Functional Syntax and Semantics
- Non-functional Quality of service
24Accessing Information About Interfaces
- In IDL-based systems
- Interfaces are described in a programming-language
- independent Interface Definition Language (IDL) - An IDL compiler processes an IDL file generating
metadata about the interface - COM Type Library
- CORBA Interface Repository
25IDLs Provide
- IDLs need to provide
- Type System
- Support of the generation of Metadata
- Language Interoperability
- Normally only cross-language method calls are
available - .NET provides cross-language inheritance
26Why Provide a Type System?
- What is an integer?
- C/C Sequence of bits
- SmallTalk A class
- Java Both (int/integer)
- IDLs normally define an integer type which is
mapped into specific programming languages
27Metadata Information
- Sharing binary components requires that
developers can inspect components to find
information about their functionality - IDLs are normally used to generate metadata
- Compiled IDL files (a components Metadata) is
stored in - Type Libraries (COM)
- Interface Repositories (CORBA)
28Execution Semantics
- IDLs can generate proxy objects which permit
cross language method calls.
29Non-IDL-Based Systems
- Java and .NET do not use an IDL, instead the
interfaces are defined along with the definition
of the components in a programming language - This eliminates the need for an IDL compiler but
places more requirements on the language compiler
30Architecture
- Overall design of a system. An architecture
integrates separate but interfering issues of a
system, such as provisions for independent
evolution and openness combined with overall
reliability and performance requirements. - Szyperski, C.,Component Software
Addison-Wesley, 1998
31Architecture
- An architecture defines guidelines that together
help to achieve the overall targets without
having to invent ad hoc compromises during system
composition. An architecture must be carefully
evolved to avoid deterioration as the system
itself evolves and the requirements change. - Szyperski, C.,Component Software
Addison-Wesley, 1998
32Architecture
- The right architectures and properly managed
architecture evolution are probably the most
important and challenging aspects of component
based software engineering. - Szyperski, C.,Component Software
Addison-Wesley, 1998
33Software Component Technologies .NET
Architecture
34.NET Framework Architecture
System.Web
System.WinForms
Controls
Drawing
Web Services
Web Forms
Windows Application Services
ASP.NET Application Services
System Base Framework
ADO.NET
XML
SQL
Threading
IO
Net
Security
ServiceProcess
Common Language Runtime
Metadata
Type System
Execution
35System
- Provides basic and fundamental .NET types and
services, such as - System.Object
- System.Type
- Most applications will be created using higher-
level abstractions in the Framework. - However, all functionality provided by the
Framework is built on top of this functionality
for example, much of the .NET functionality
depends on Reflection.
36System
- ...
- static int Main(string args)
-
- System.String s "Hello World!"
- System.Type t s.GetType()
- System.Console.Out.WriteLine(t.ToString())
- return 0
-
37System
38System.Reflection
- Provides types that allows programs to
dynamically - Inspect the Type System
- Extend the Type System (create new types at
runtime) - Create instances and invoke methods on types
39System.Reflection
- using System
- using System.Reflection
- namespace Damien
-
- public class TypeInfo
-
- public static void Main(String args)
-
- ...
-
-
40System.Reflection
- public static void Main(String args)
-
- Type t Type.GetType("System.String")
- Console.WriteLine(t.FullName)
- Console.WriteLine(t.AssemblyQualifiedName)
- Console.WriteLine(t.BaseType)
- MethodInfo ma t.GetMethods()
- for(int i 0 i lt ma.Length i)
- Console.WriteLine(mai)
-
41System.Reflection
- Object a new Object1
- a0 "Hello World"
- Object o Activator.CreateInstance(t, a)
- Type p new Type2
- p0 Type.GetType("System.Int32")
- p1 Type.GetType("System.String")
- MethodInfo m t.GetMethod("Insert",p)
-
42System.Reflection
- Console.WriteLine("Invoking this method")
- Console.WriteLine(m)
- a new Object2
- a0 0
- a1 "Hello World "
- Console.WriteLine(m.Invoke(o, a))
-
43System.Reflection
- using System
- using System.Reflection
- using System.Text
- AttributeUsage(AttributeTargets.ClassMembers,
- AllowMultiple true)
- public class AuthorAttribute System.Attribute
-
- public String Author
- ...
44System.Reflection
- public class AuthorAttribute System.Attribute
-
- public String Author
- public AuthorAttribute(String Author)
-
- this.Author Author
-
- override public String ToString()
-
- return new StringBuilder("Author "
- Author).ToString()
-
45System.Reflection
- Author("Damien Watkins")
- class ProgrammingAssignment
-
- Author("Mark Hammond")
- public ProgrammingAssignment()
-
- Console.WriteLine("Constructor")
-
- public static void Main()
-
- ...
46System.Reflection
- public static void Main()
-
- Type t Type.GetType("ProgrammingAssignment")
- Console.WriteLine(t.AssemblyQualifiedName)
- Object Attributes t.GetCustomAttributes()
- Console.WriteLine("Number of attributes is
- Attributes.Length)
- for (int i 0 i lt Attributes.Length i)
- Console.WriteLine(Attributesi)
- ...
47System.Collections
- Provides basic collection types, such as
- System.ArrayList
- System.Hashtable
- System.Stack
- Unfortunately, these structures are based on
System.Object. - There is a real need for true generics!
48System.Collections
- Hashtable ht new Hashtable()
- ht.Add( "Apple", "Green" )
- ht.Add( "Oragne", "Orange" )
- ht.Add( "Green", "Grape" )
- Console.WriteLine("Number of items "
- ht.Count)
- IDictionaryEnumerator e ht.GetEnumerator()
- while(e.MoveNext())
- Console.WriteLine("Key " e.Key
- "Value " e.Value )
49.NET Framework Architecture
System.Web
System.WinForms
Controls
Drawing
Web Services
Web Forms
Windows Application Services
ASP.NET Application Services
System Base Framework
ADO.NET
XML
SQL
Threading
IO
Net
Security
ServiceProcess
Common Language Runtime
Metadata
Type System
Execution
50Base Framework
- Contains a number of classes that generally
provide an abstraction that covers an area of
programming - For example, System.Threading provides an
abstraction of writing multi-threaded programs
that can be used across languages
51System.Threading
- using System
- using System.Threading
- class ThreadClass
-
- public void StartHere()
-
- Console.WriteLine("Thread starting")
- Thread.Sleep(0)
- Console.WriteLine("Thread ending")
-
- ...
52System.Threading
- public static int Main()
-
- Console.WriteLine("Main Thread started")
- ThreadClass tc new ThreadClass()
- Thread t new Thread(
- new ThreadStart(tc.StartHere))
- t.Start()
- ...
53System.Threading
- Console.WriteLine("t has been started")
- Thread.Sleep(0)
- while (
- (t.ThreadStateThreadState.Unstarted)!0)
- Console.WriteLine("Main Thread ending")
- return 0
-
54System.ComponentModel
- Provides .NET types that support the Component
Model, such as - Component
- Attributes
- Type Conversions
55System.ComponentModel
- AttributeCollection ac TypeDescriptor.GetAttribu
tes(button1) - BrowsableAttribute a BrowsableAttribute.Yes
- if(ac.Contains(a))
- MessageBox.Show("Browsable")
- else
- MessageBox.Show("Not Browsable")
56System.ComponentModel
- using System
- using System.ComponentModel
- ...
- BooleanConverter b new BooleanConverter()
- String s "false"
- if(b.CanConvertTo(s.GetType()))
-
- Object o b.ConvertFrom(s)
- Console.Out.WriteLine(o)
-
57System.XML
- using System
- using System.Xml
- using System.Xml.Serialization
- using System.IO
- public class Name
-
- ...
58System.XML
- public class Name
-
- public Name()
- public Name(string Family, string Given)
-
- this.Family Family
- this.Given Given
-
- public string Family
- private string Given
59System.XML
- public class Test
-
- public static int Main()
-
- Name Damien new Name("Watkins", "Damien")
- XmlSerializer XMLoutput
- new XmlSerializer(Damien.GetType())
- StringWriter sw new StringWriter()
- XMLoutput.Serialize(sw, Damien)
- Console.WriteLine(sw.ToString())
- return 0
-
60System.Data.ADO
- ADOConnection myConnection new
ADOConnection("Provider ") - ADODataSetCommand myCommand new
ADODataSetCommand("SELECT ", myConnection) - DataSet ds new DataSet()
- myCommand.FillDataSet(ds, "Subjects")
- Subjects.DataSource ds.Tables0.DefaultView
- Subjects.DataBind()
61.NET Framework Architecture
System.WinForms
System.Web
Web Services
Web Forms
Controls
Drawing
ASP.NET Application Services
Windows Application Services
System Base Framework
ADO.NET
XML
SQL
Threading
IO
Net
Security
ServiceProcess
Common Language Runtime
Metadata
Type System
Execution
62ASP.NET
- Provides a means of exposing the .NET Framework
and its functionality to the WWW - Contains a number of pre-built types that take
input from .NET types and represents them in a
form for the web (such as HTML)
63ASP.NET
- In the following example, a DataList, named
studentList - Takes its input from a C array object, which is
located in a C file - Displays it on a aspx page in HTML
64ASP.NET
- ltaspDataList runatserver
- id"studentList"
- RepeatColumns"2"
- RepeatDirection"Vertical"
- RepeatMode"Table"
- Width"100"gt
- ...
- lt/aspDataListgt
65ASP.NET
- ltaspDataList runatserver ...
- ltproperty name"AlternatingItemStyle"gt
- ltaspTableItemStyle BackColor"yellow"/gt
- lt/propertygt
- lttemplate name"ItemTemplate"gt
- ltaspPanel runatserver font-size"12pt
- font-bold"true"gt
- lt ((Student)Container.DataItem).Name gt
- lt/aspPanelgt
- ltaspPanel runatserver font-size"12pt"gt
- lt ((Student)Container.DataItem).Number gt
- lt/aspPanelgt lt/templategt
66Web Services
- Web Services also provides ameans to expose .NET
functionality on the web but Web Services expose
functionality via XML and SOAP
67System.Web.Services
- namespace WebServiceDemo
- ...
- using System.Web.Services
- public class WebService1 System.Web.Services.W
ebService -
- WebMethod
- public string HelloWorld()
- ...
68.NET Framework Architecture
System.Windows
System.Web
Controls
Drawing
Web Services
Web Forms
Windows Application Services
ASP.NET Application Services
System Base Framework
ADO.NET
XML
SQL
Threading
IO
Net
Security
ServiceProcess
Common Language Runtime
Metadata
Type System
Execution
69System.WinForms
- Provides .NET types for building Windows
Applications - System.WinForms.Form
70System.Windows
- namespace Test
-
- using System
- ...
- using System.WinForm.Forms
- public class Form1
- System.WinForm.Forms.Form
-
- private System.Windows.Forms.Button b1
71Summary
- There are too many classes to cover them all!
- Recommendation When you need to add some
functionality into your application, look in the
Architecture.