Presentation is loading. Please wait.

Presentation is loading. Please wait.

Component-Based Software Engineering Component process.

Similar presentations


Presentation on theme: "Component-Based Software Engineering Component process."— Presentation transcript:

1 Component-Based Software Engineering Component process

2 Exist Component

3 The component identification process

4 Connector Design :Button :Motor :Meter pressed start stop speed value

5 Connector Design :Button :Motor :Meter pressed start stop speed value :OR :Threshold a b a  b a > b a < b :Multiplier :Selector {1, 10, 100} :Selector {1, 10, 100} ab a x b 5:int a b

6 Component Engineering For those requirements that are addressed with available components, the following software engineering activities must be done: For those requirements that are addressed with available components, the following software engineering activities must be done: 1. Component qualification 2. Component adaptation. 3. Component composition. 4. Component update.

7 Component qualification  Component qualification ensures that a candidate component will perform the function required, will perform the function required, will properly fit into the architectural style specified for the system, and will properly fit into the architectural style specified for the system, and will exhibit the quality characteristics (e.g., performance, reliability, usability) required for the application. will exhibit the quality characteristics (e.g., performance, reliability, usability) required for the application.

8 Component adaptation  In some cases, existing components may be mismatched to the architecture’s design rules. These components must be adapted to meet the needs of the architecture  adaptation technique called “component wrapping” is often used.

9 Component adaptation--wrapping  When a software team has full access to the internal design and code for a component, white-box wrapping is applied. This wrapping examines the internal processing details and makes code-level modifications to remove any conflicts.  Grey-box wrapping is applied when the component library provides a component extension language or API that enables conflicts to be removed or masked.  Black-box wrapping requires the introduction of pre- and post-processing at the component interface to remove or mask conflicts.

10 Component composition  The process of assembling components to create a system.  Composition involves integrating components with each other and with the component infrastructure.

11 Types of composition  Sequential composition where the composed components are executed in sequence. This involves composing the provides interfaces of each component.  Hierarchical composition where one component calls on the services of another. The provides interface of one component is composed with the requires interface of another.  Additive composition where the interfaces of two components are put together to create a new component.

12 Types of composition

13 Interface incompatibility  Parameter incompatibility where operations have the same name but are of different types.  Operation incompatibility where the names of operations in the composed interfaces are different.  Operation incompleteness where the provides interface of one component is a subset of the requires interface of another.

14 Incompatible components

15 Composition through an adaptor  The component postCodeStripper is the adaptor that facilitates the sequential composition of addressFinder and mapper components.

16 Adaptor for data collector

17 Photo library composition

18 Component update  When systems are implemented with components, update is complicated by the imposition of a third party. The organization that developed the reusable component may be outside the immediate control of the software engineering organization.

19 New Component

20 Again, What is a component ?  A component makes its services available through interfaces and interfaces are of certain types or categories

21 Printing Services Component

22 Component Abstractions  Functional abstraction The component implements a single function such as a mathematical function The component implements a single function such as a mathematical function  Data abstractions The component represents a class in an object- oriented language The component represents a class in an object- oriented language  Cluster abstractions The component is a group of related classes that work together The component is a group of related classes that work together  System abstraction The component is an entire self-contained system The component is an entire self-contained system

23 23 New Component  To design and develop the internals of a components we distinguish four levels of abstraction Component specificationComponent specification Component implementationComponent implementation Component executableComponent executable Component deploymentComponent deployment  The process can be carried out using techniques like UML and OO programming languages, and methodologies supporting component production.

24 Component Specification  Provides Interfaces The services a component can offer to a client The services a component can offer to a client  Requires Interfaces The services required by a component to help it deliver its promises The services required by a component to help it deliver its promises  Context of Use The “world” the component lives in The “world” the component lives in

25 25 Component implementation  It defines the inside of a component, with its internal parts and collaborations.  It occurs after the decision of the programming language to use for the development  It must satisfies the specification One-to-many relationship One-to-many relationship

26 26 Component executable  It is the real pluggable component used in the assembly of the application  Each executable may results in more than one version There may be more than one executable per implementation There may be more than one executable per implementation

27 27 Component deployment  It is the deployment of the component executable on a number of nodes  There may be several deployment for the same executable.

28 Component Programming with C# and.NET

29 C# components  The most commonly used components in.NET are the visual controls that you add to Windows Forms such as the Button Control (Windows Forms), ComboBox Control (Windows Forms), and so on. Button Control (Windows Forms)ComboBox Control (Windows Forms)Button Control (Windows Forms)ComboBox Control (Windows Forms)  Non-visual components include the Timer Control, SerialPort, and ServiceController among others. Timer ControlSerialPortServiceControllerTimer ControlSerialPortServiceController

30 What defines a component?  What defines a component in C#? Properties, methods, events Properties, methods, events Design-time and runtime information Design-time and runtime information Integrated help and documentation Integrated help and documentation

31 AP 08/01 public class Button: Control { private string caption; private string caption; public string Caption { public string Caption { get { get { return caption; return caption; } set { set { caption = value; caption = value; Repaint(); Repaint(); } }} Properties  Properties are “smart fields” Natural syntax, accessors, inlining Natural syntax, accessors, inlining Button b = new Button(); b.Caption = "OK"; String s = b.Caption;

32 AP 08/01 Indexers  Indexers are “smart arrays” Can be overloaded Can be overloaded public class ListBox: Control { private string[] items; public string this[int index]{ get { return items[index]; } set { items[index] = value; Repaint(); } ListBox listBox = new ListBox(); listBox[0] = "hello"; Console.WriteLine(listBox[0]);

33 AP 08/01 Events  Efficient, type-safe and customizable Built on delegates Built on delegates public class MyForm: Form { public MyForm() { Button okButton = new Button(...); okButton.Click += new EventHandler(OkButtonClick); } void OkButtonClick(…) { ShowMessage("You clicked OK"); }

34 Events  Events enable a class or object to notify other classes or objects when something of interest occurs class  The class that sends (or raises) the event is called the publisher and the classes that receive (or handle) the event are called subscribers.

35 Example  Arithmetic component which does addition  We will create a component called CSAddComp1 and package it into a dll (Dynamic Linked Library).  This component has two properties and a method.  Properties take input for the addition and method called Sum( ).

36 Example  To create properties in C# you use the get and set accessors.  The get accessor is used for getting (reading).  The set accessor for setting (writing) the property

37 Component Program using System; namespace CompCS { public class CSAddComp1 { private int varI=0,varJ=0; public int varI { get { return varI; } //this is property get for varI set { varI=value; } //this is property set for varI } public int varJ { get { return varJ; } // this is property get for varJ set { varJ=value; } // this is property set for varJ } public int Sum() { return varI+varJ; //this returns the sum of two variables } } //end of class } } //end of class } //end of namespace } //end of namespace

38 DLL package DLL package  To package the component as dll there is slight change in usual compilation process.  Its little complicated process when compared to normal stand-alone program compilation. csc /out:CSAddComp1.dll /target:library CSAddComp1.cs  Here the /out switch to put the compiled component in the relative subdirectory and file for convenience.  Likewise, we need the /target:library switch to actually create a DLL rather than an executable with a.dll file extension.

39 client program client program using System; using CompCS; class clAddComp1 { public static void Main() { CSAddComp1 addComp= new CSAddComp1(); addComp.varI=10; //property set for varI addComp.varJ=20; //property set for varJ //below property get for varI Console.WriteLine("variable I value : {0}",addComp.varI); //below property get for varJ Console.WriteLine("variable J value : {0}",addComp.varJ); // calling Sum(..) method Console.WriteLine("The Sum : {0}",addComp.Sum()); } //end of Main } // end of Class

40 Component Designer in C# Component Designer in C#  To display the designer, from the Project menu, select Add Component.  The Add New Item dialog box appears.  By default, the Component Class item is selected.  Click OK to add a new component to project and open the Component Designer.  http://www.youtube.com/watch?v=DgAqyYO20nY http://www.youtube.com/watch?v=DgAqyYO20nY

41 As an example, to package the alarm functionality we built the Timer component, let's build anAlarmComponent class. To create a new component class, right-click on the project and choose Add | Add Component, enter the name of your component class, and press OK. You'll be greeted with a blank design surface,

42

43 using System; using System.ComponentModel; using System.Collections; using System.Diagnostics; using System.Diagnostics; namespace Components { public class AlarmComponent : System.ComponentModel.Component { private Timer timer1; private System.ComponentModel.IContainer components; private System.ComponentModel.IContainer components; public AlarmComponent(System.ComponentModel.IContainer container) { container.Add(this); InitializeComponent(); InitializeComponent(); } } public AlarmComponent() { InitializeComponent(); } InitializeComponent(); } private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1.Enabled = true; }}}

44 Attributes  We can use attributes to define both design-level information (such as help file, URL for documentation) and run- time information (such as associating XML field with class field).  We can also create "self-describing" components using attributes.

45 Attributes [HelpUrl(“http://SomeUrl/Docs/SomeClass”)] class SomeClass { [WebMethod] void GetCustomers() { … } string Test([SomeAttr] string param1) {…} }  Appear in square brackets  Attached to code elements

46 Apply attributes  Define a new attribute or use an existing attribute by importing its namespace from the.NET Framework.

47 Example using System; public class AnyClass { [Obsolete("Don't use Old method, use New method", true)] static void Old( ) { } static void New( ) { } public static void Main( ) { Old( ); } }

48 Example  we use attribute Obsolete, which marks a program entity that should not be used.  The first parameter is the string that can be any text.  The second parameter tells the compiler to treat the use of the item as an error.  Default value is false, which means compiler generates a warning for this.

49 Attribute Fundamentals  Attributes are classes! Completely generic class HelpUrl : System.Attribute { public HelpUrl(string url) { … } … } [HelpUrl(“http://SomeUrl/APIDocs/SomeClass”)] class SomeClass { … }

50 Attributes to specify DLL Imports [DllImport("gdi32.dll",CharSet=CharSet.Auto)] public static extern int GetObject( int hObject, int nSize, [In, Out] ref LOGFONT lf); [DllImport("gdi32.dll")] public static extern int CreatePen(int style, int width, int color);

51 Component & attributes  components can be displayed in a designer, such as Visual Studio.NET, but required attributes that provide metadata to design-time tools.  A DesignerAttribute attribute is applied at the class level and informs the forms designer which designer class to use to display the control.  Components are associated with a default designer (System.ComponentModel.Design.ComponentDesig ner), and Windows Forms and ASP.NET server controls are associated with their own default designers.  Apply DesignerAttribute only if you define a custom designer for your component or control.

52 To add a security attribute to a code member of your component using System.Security.Permissions; [FileIOPermission(SecurityAction.Demand)] public void FileDeleter() { // Insert code to delete files. }

53 COM Support .NET Framework provides great COM support TLBIMP imports existing COM classes TLBIMP imports existing COM classes TLBEXP exports.NET types TLBEXP exports.NET types  Most users will have a seamless experience

54 Building COM components using.NET Framework  Create C# - Class Library project  Develop the AccountManager.cs library  Modify the generated AssemblyInfo.cs to add the right assembly information  Build the Project Files  Deploy the component as a Shared Assembly, and Configure the Assembly in the COM+ Catalog

55

56 Configure your Project Property Pages with the right information

57

58 add the right assembly information [assembly: AssemblyTitle("AccountManager for Bank")] [assembly: AssemblyDescription("Creates and Deletes Accounts for the Bank")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("eCommWare Corporation")] [assembly: AssemblyProduct("COM+ Bank Server")] [assembly: AssemblyCopyright("(c) 2001, Gopalan Suresh Raj. All Rights Reserved.")] [assembly: AssemblyTrademark("Web Cornucopia")] [assembly: AssemblyCulture("en-US")]

59 Calling into a COM component  Create.NET assembly from COM component via tlbimp  Client apps may access the newly created assembly using System; using System.Runtime.InteropServices; using CONVERTERLib; class Convert { public static void Main(string [] args) { CFConvert conv = new CFConvert();... fahrenheit = conv.CelsiusToFahrenheit( celsius );


Download ppt "Component-Based Software Engineering Component process."

Similar presentations


Ads by Google