Software Component Technologies Introduction 1 What Are Components





![What Are Software Components? n n “A [software] component is a unit of composition What Are Software Components? n n “A [software] component is a unit of composition](https://slidetodoc.com/presentation_image_h2/d4e1eaf006086149e31fecdcc82c253f/image-6.jpg)





























![System. . . static int Main(string[] args) { System. String s = "Hello World!"; System. . . static int Main(string[] args) { System. String s = "Hello World!";](https://slidetodoc.com/presentation_image_h2/d4e1eaf006086149e31fecdcc82c253f/image-36.jpg)



![System. Reflection public static void Main(String[] args) { Type t = Type. Get. Type("System. System. Reflection public static void Main(String[] args) { Type t = Type. Get. Type("System.](https://slidetodoc.com/presentation_image_h2/d4e1eaf006086149e31fecdcc82c253f/image-40.jpg)
![System. Reflection Object[] a = new Object[1]; a[0] = "Hello World"; Object o = System. Reflection Object[] a = new Object[1]; a[0] = "Hello World"; Object o =](https://slidetodoc.com/presentation_image_h2/d4e1eaf006086149e31fecdcc82c253f/image-41.jpg)
![System. Reflection Console. Write. Line("Invoking this method"); Console. Write. Line(m); a = new Object[2]; System. Reflection Console. Write. Line("Invoking this method"); Console. Write. Line(m); a = new Object[2];](https://slidetodoc.com/presentation_image_h2/d4e1eaf006086149e31fecdcc82c253f/image-42.jpg)


![System. Reflection [Author("Damien Watkins")] class Programming. Assignment { [Author("Mark Hammond")] public Programming. Assignment() { System. Reflection [Author("Damien Watkins")] class Programming. Assignment { [Author("Mark Hammond")] public Programming. Assignment() {](https://slidetodoc.com/presentation_image_h2/d4e1eaf006086149e31fecdcc82c253f/image-45.jpg)


























- Slides: 71

Software Component Technologies: Introduction 1

What Are Components? n “A consistent part. ” - Macquarie Dictionary 1985 n n An identifiable part of the whole Components are possibly: ¡ ¡ Replaceable Interchangeable n n A means of supplying variation They are only a part, not the whole 2

What Are Components? n Examples of components: ¡ ¡ n 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? 3

Why Use Components? n Components simplify the process of building systems: ¡ ¡ Promote reuse of both design and implementation Allow specialization n n Camera manufacturers need not also make films Can the ideas of components be successfully applied to developing software? 4

What Are Software Components? n “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] 5
![What Are Software Components n n A software component is a unit of composition What Are Software Components? n n “A [software] component is a unit of composition](https://slidetodoc.com/presentation_image_h2/d4e1eaf006086149e31fecdcc82c253f/image-6.jpg)
What Are Software Components? n n “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, 6

What Are Software Components? n “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] 7

Interfaces n “A surface regarded as the common boundary to two bodies or spaces. ” - Macquarie Dictionary 1985 n n An interface is a point of contact Interfaces are contracts with rights and obligations for both sides 8

What Are Interfaces? n Hard disk ¡ n IDE, SCSI Electrical Power. Point ¡ ¡ TV, Radio, Laptop, Light, Microwave Variations exist n USA, Australian, British 9

What Are Software Interfaces? n “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] 10

What Are Interfaces? n n n Interfaces are often described using an Interface Definition Language (IDL) IDLs are programming-language independent Which is more important, the component or its interface? 11

What Is Component Based Development n 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] 12

Software Component Technologies n n n Microsoft’s Component Object Model (COM) Sun’s Enterprise Java Beans CORBA and CORBA’s Components ¡ n EJB is a compliant implementation Microsoft’s. NET Framework 13

Issues Involved in CBD n Issues can occur because of: ¡ Differing machine architectures n ¡ Programming languages n ¡ Word sizes OO, Functional, Imperative Operating systems n Different instruction sets 14

Solutions n Common Type System ¡ n Metadata Information ¡ ¡ n Standardized types and user defined types IDL files Reflection Common Execution Semantics ¡ ¡ Cross language method invocation, COM and CORBA Virtual Machines 15

Common Type System n What is an integer? ¡ ¡ ¡ n n C/C++: Sequence of bits Small. Talk: 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 16

Metadata Information n n 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 (Small. Talk/Java/. NET) However, Reflection is normally not used across language boundaries. 17

Execution Semantics n Need to abstract about elements of execution, such as: ¡ ¡ ¡ Calling semantics Object Models Data Access 18

Execution Semantics n Method call level ¡ n Object models ¡ n COM/CORBA Interface based, COM/CORBA Full-language semantics ¡ Small. Talk, Java, . NET (but this is often language specific) 19

What Are Interfaces? n If interfaces are the publicly exposed methods that a client can call on a server, how do clients obtain the specification of these interfaces? 20

Accessing Information About Interfaces n Component architectures generally use one of two methods to provide information about interfaces: ¡ An abstract Interface Definition Language: n n ¡ 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 21

What Are IDLs? n “Used to define an interface according to a certain model (usually an object model) in a programming languageneutral form. ” - Szyperski, C. , Component Software [Addison-Wesley, 1998] n IDLs specify contracts 22

What Are Contracts? n “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] n Functional – Syntax and Semantics 23

Accessing Information About Interfaces n 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 24

IDLs Provide n IDLs need to provide: ¡ ¡ ¡ Type System Support of the generation of Metadata Language Interoperability n n Normally only cross-language method calls are available. NET provides cross-language inheritance 25

Why Provide a Type System? n n n What is an integer? C/C++: Sequence of bits Small. Talk: A class Java: Both (int/integer) IDLs normally define an integer type which is mapped into specific programming languages 26

Metadata Information n 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 component’s Metadata) is stored in ¡ Type Libraries (COM) 27

Execution Semantics n IDLs can generate proxy objects which permit cross language method calls. 28

Non-IDL-Based Systems n n 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 29

Architecture n “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] - 30

Architecture n “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, - 31

Architecture n 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] - 32

Software Component Technologies: . NET Architecture 33

. NET Framework Architecture System. Win. Forms System. Web Services Web Forms ASP. NET Application Services Controls Drawing Windows Application Services System Base Framework ADO. NET XML SQL Threading IO Net Security Service. Process Common Language Runtime Type System Metadata Execution 34

System n Provides basic and fundamental. NET types and services, such as: ¡ ¡ n n 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. 35
![System static int Mainstring args System String s Hello World System. . . static int Main(string[] args) { System. String s = "Hello World!";](https://slidetodoc.com/presentation_image_h2/d4e1eaf006086149e31fecdcc82c253f/image-36.jpg)
System. . . static int Main(string[] args) { System. String s = "Hello World!"; System. Type t = s. Get. Type(); System. Console. Out. Write. Line(t. To. Str ing()); return 0; } } 36

System 37

System. Reflection n 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 38

System. Reflection using System; using System. Reflection; namespace Damien { public class Type. Info { public static void Main(String[] args) {. . . } 39
![System Reflection public static void MainString args Type t Type Get TypeSystem System. Reflection public static void Main(String[] args) { Type t = Type. Get. Type("System.](https://slidetodoc.com/presentation_image_h2/d4e1eaf006086149e31fecdcc82c253f/image-40.jpg)
System. Reflection public static void Main(String[] args) { Type t = Type. Get. Type("System. String"); Console. Write. Line(t. Full. Name); Console. Write. Line(t. Assembly. Qualified. Name) ; Console. Write. Line(t. Base. Type); Method. Info[] ma = t. Get. Methods(); for(int i = 0; i < ma. Length; i++) Console. Write. Line(ma[i]); 40
![System Reflection Object a new Object1 a0 Hello World Object o System. Reflection Object[] a = new Object[1]; a[0] = "Hello World"; Object o =](https://slidetodoc.com/presentation_image_h2/d4e1eaf006086149e31fecdcc82c253f/image-41.jpg)
System. Reflection Object[] a = new Object[1]; a[0] = "Hello World"; Object o = Activator. Create. Instance(t, a); Type[] p = new Type[2]; p[0] = Type. Get. Type("System. Int 32"); p[1] = Type. Get. Type("System. String"); Method. Info m = t. Get. Method("Insert", p); 41
![System Reflection Console Write LineInvoking this method Console Write Linem a new Object2 System. Reflection Console. Write. Line("Invoking this method"); Console. Write. Line(m); a = new Object[2];](https://slidetodoc.com/presentation_image_h2/d4e1eaf006086149e31fecdcc82c253f/image-42.jpg)
System. Reflection Console. Write. Line("Invoking this method"); Console. Write. Line(m); a = new Object[2]; a[0] = 0; a[1] = "Hello World "; Console. Write. Line(m. Invoke(o, a)); } 42

System. Reflection using System; using System. Reflection; using System. Text; [Attribute. Usage(Attribute. Targets. Class. Me mbers, Allow. Multiple = true)] public class Author. Attribute : System. Attribute { public String Author; 43

System. Reflection public class Author. Attribute : System. Attribute { public String Author; public Author. Attribute(String Author) { this. Author = Author; } override public String To. String() { return new String. Builder("Author: " 44
![System Reflection AuthorDamien Watkins class Programming Assignment AuthorMark Hammond public Programming Assignment System. Reflection [Author("Damien Watkins")] class Programming. Assignment { [Author("Mark Hammond")] public Programming. Assignment() {](https://slidetodoc.com/presentation_image_h2/d4e1eaf006086149e31fecdcc82c253f/image-45.jpg)
System. Reflection [Author("Damien Watkins")] class Programming. Assignment { [Author("Mark Hammond")] public Programming. Assignment() { Console. Write. Line("Constructor"); } public static void Main() {. . . 45

System. Reflection public static void Main() { Type t = Type. Get. Type("Programming. Assignment"); Console. Write. Line(t. Assembly. Qualified. N ame); Object[] Attributes = t. Get. Custom. Attributes(); Console. Write. Line("Number of attributes is: “ + Attributes. Length); 46 for (int i = 0; i < Attributes. Length;

System. Collections n Provides basic collection types, such as: ¡ ¡ ¡ n n System. Array. List System. Hashtable System. Stack Unfortunately, these structures are based on System. Object. There is a real need for true generics! 47

System. Collections Hashtable ht = new Hashtable(); ht. Add( "Apple", "Green" ); ht. Add( "Oragne", "Orange" ); ht. Add( "Green", "Grape" ); Console. Write. Line("Number of items: " + ht. Count); IDictionary. Enumerator e = ht. Get. Enumerator(); while(e. Move. Next()) Console. Write. Line("Key: " + e. Key + "Value: " + e. Value ); 48

. NET Framework Architecture System. Win. Forms System. Web Services Web Forms ASP. NET Application Services Controls Drawing Windows Application Services System Base Framework ADO. NET XML SQL Threading IO Net Security Service. Process Common Language Runtime Type System Metadata Execution 49

Base Framework n n 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 multithreaded programs that can be used across languages 50

System. Threading using System; using System. Threading; class Thread. Class { public void Start. Here() { Console. Write. Line("Thread starting"); Thread. Sleep(0); Console. Write. Line("Thread ending"); } 51. . .

System. Threading public static int Main() { Console. Write. Line("Main Thread started"); Thread. Class tc = new Thread. Class(); Thread t = new Thread( new Thread. Start(tc. Start. Here)); t. Start(); . . . 52

System. Threading Console. Write. Line("t has been started"); Thread. Sleep(0); while ( (t. Thread. State&Thread. State. Unstarted )!=0); Console. Write. Line("Main Thread ending"); return 0; } } 53

System. Component. Model n Provides. NET types that support the Component Model, such as: ¡ ¡ ¡ Component Attributes Type Conversions 54

System. Component. Model Attribute. Collection ac = Type. Descriptor. Get. Attributes(button 1); Browsable. Attribute a = Browsable. Attribute. Yes; if(ac. Contains(a)) Message. Box. Show("Browsable"); else Message. Box. Show("Not Browsable"); 55

System. Component. Model using System; using System. Component. Model; . . . Boolean. Converter b = new Boolean. Converter(); String s = "false"; if(b. Can. Convert. To(s. Get. Type())) { Object o = b. Convert. From(s); Console. Out. Write. Line(o); } 56

System. XML using System; System. Xml. Serialization; System. IO; public class Name {. . . } 57

System. XML public class Name { public Name(){} public Name(string Family, string Given) { this. Family = Family; this. Given = Given; } public string Family; private string Given; 58

System. XML public class Test { public static int Main() { Name Damien = new Name("Watkins", "Damien"); Xml. Serializer XMLoutput = new Xml. Serializer(Damien. Get. Type()); String. Writer sw = new String. Writer(); XMLoutput. Serialize(sw, Damien); 59 Console. Write. Line(sw. To. String());

System. Data. ADOConnection my. Connection = new ADOConnection("Provider …"); ADOData. Set. Command my. Command = new ADOData. Set. Command("SELECT …", my. Connection); Data. Set ds = new Data. Set(); my. Command. Fill. Data. Set(ds, "Subjects"); Subjects. Data. Source = ds. Tables[0]. Default. View; Subjects. Data. Bind(); 60

. NET Framework Architecture System. Win. Forms System. Web Services Web Forms ASP. NET Application Services Controls Drawing Windows Application Services System Base Framework ADO. NET XML SQL Threading IO Net Security Service. Process Common Language Runtime Type System Metadata Execution 61

ASP. NET n n 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) 62

ASP. NET n In the following example, a Data. List, named student. List: ¡ ¡ Takes its input from a C# array object, which is located in a C# file Displays it on a aspx page in HTML 63

ASP. NET <asp: Data. List runat=server id="student. List" Repeat. Columns="2" Repeat. Direction="Vertical" Repeat. Mode="Table" Width="100%">. . . </asp: Data. List> 64

ASP. NET <asp: Data. List runat=server. . . <property name="Alternating. Item. Style"> <asp: Table. Item. Style Back. Color="yellow"/> </property> <template name="Item. Template"> <asp: Panel runat=server fontsize="12 pt“ fontbold="true"> <%# ((Student)Container. Data. Item). Name %> 65

Web Services n Web Services also provides ameans to expose. NET functionality on the web but Web Services expose functionality via XML and SOAP 66

System. Web. Services namespace Web. Service. Demo {. . . using System. Web. Services; public class Web. Service 1 : System. Web. Services. Web. Service { [Web. Method] public string Hello. World(). . . } 67

. NET Framework Architecture System. Windows System. Web Services Web Forms ASP. NET Application Services Controls Drawing Windows Application Services System Base Framework ADO. NET XML SQL Threading IO Net Security Service. Process Common Language Runtime Type System Metadata Execution 68

System. Win. Forms n n Provides. NET types for building Windows Applications System. Win. Forms. Form 69

System. Windows namespace Test { using System; . . . using System. Win. Forms; public class Form 1 : System. Win. Forms. F orm { private System. Windows. Forms. Button b 1; 70

Summary n n There are too many classes to cover them all! Recommendation: When you need to add some functionality into your application, look in the Architecture. 71