Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2:...

32
1 Università La Sapienza Ingegneria del Software I Ingegneria del software I Seminario 2: Microsoft .NET

Transcript of Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2:...

Page 1: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

1Università La Sapienza

Ingegneria del Software I

Ingegneria del software I

Seminario 2: Microsoft .NET

Page 2: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

2Università La Sapienza

Ingegneria del Software I

Microsoft.NET piattaforma

Visual Studio.NETVisual Studio.NET .NET Enterprise Servers.NET Enterprise Servers

.NET Building Block & Services

.NET Building Block & Services

.NET Devices, User Experience

.NET Devices, User Experience

Page 3: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

3Università La Sapienza

Ingegneria del Software I

Microsoft.NET piattaforma

Visual Studio.NETVisual Studio.NET .NET Enterprise Servers.NET Enterprise Servers

.NET Building Block & Services

.NET Building Block & Services

.NET Devices, User Experience

.NET Devices, User Experience

Page 4: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

4Università La Sapienza

Ingegneria del Software I

Visual Studio.NET

• Framework per sviluppo ed integrazione dei .NET Enterprise Servers sia con .NET building block services che .NET devices. [6]

VBVB C++C++ C#C# ScriptsScripts ……

CLS (Common Language Specification)CLS (Common Language Specification)

ASP.NETASP.NET

Web ServiceWeb Service Web FormWeb Form

ADO.NET : Data and XMLADO.NET : Data and XML

Base Class LibraryBase Class Library

CLR (Common Language Runtime)CLR (Common Language Runtime)

Integrates intothe system

Page 5: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

5Università La Sapienza

Ingegneria del Software I

CLS (Common Language Specification)

• È un insieme di specifiche per l’interoperabilità tra linguaggi. [7]

• È un insieme di specifiche di compilazione per l’indipendenza dai linguaggi. [8]

• Sono definiti: tipi, metodi, campi, proprietà, enumerazioni, eccezioni, interfacce, eventi, etc.

Page 6: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

6Università La Sapienza

Ingegneria del Software I

CLR (Common Language Runtime)

• Carica ed esegue codice scritto in runtime-aware per i linguaggi di programmazione. [14]

• Le caratteristiche dell’ambiente runtime [14] :– cross-language integration– self-describing components– simple deployment and versioning – integrated security services.

• Un unico framework per il progetto, lo sviluppo, l’implementazione, e l’esecuzione di componenti ed applicazioni distribuiti. [9]

Page 7: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

7Università La Sapienza

Ingegneria del Software I

Microsoft.NET Platform

Visual Studio.NETVisual Studio.NET .NET Enterprise Servers.NET Enterprise Servers

.NET Building Block & Services

.NET Building Block & Services

.NET Devices, User Experience

.NET Devices, User Experience

Page 8: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

8Università La Sapienza

Ingegneria del Software I

Mainframe / Other

Data Sources

Supplier / Consumer

of XML e-documents

.NET Enterprise Server Configuration

Internet Security

& Acceleration

Server 2000

Internet Security

& Acceleration

Server 2000

SQL Server 2000SQL Server 2000

Host Integration

Server 2000

Host Integration

Server 2000

BizTalk

Server 2000

BizTalk

Server 2000

Application Center 2000Application Center 2000

Internet Information ServerInternet Information Server

Exchange

Server 2000

Exchange

Server 2000

COM+COM+

Mobile Information

Server 2000

Mobile Information

Server 2000

Clients on the web

Mobile Devices

Page 9: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

9Università La Sapienza

Ingegneria del Software I

Microsoft .NET Framework

System ServicesSystem Services

Common Language RuntimeCommon Language Runtime

Services FrameWorkServices FrameWorkBase Data Debug . . .

ASP+ASP+Web Forms Web Services

Win FormsWin Forms

Page 10: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

10Università La Sapienza

Ingegneria del Software I

Service Framework• Fornisce classi di oggetti a supporto degli

sviluppatori per .NET. [14]

Base ClassesBase Classes

Type System

Component Model

I/O and Network

Drawing (GDI+)

Threading

Cryptography

Globalization

Serialization

Programming Tools

Programming ToolsDebugging/Trace

Configuration/Install

Resources

EventLog/PerfCounter

Page 11: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

11Università La Sapienza

Ingegneria del Software I

Il linguaggio C#

• Caratteristiche del C# [16]

– Semplicità– Type safe– Consistenza– Supporto alle versioni– Object Orientation– Flessibilità

Page 12: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

12Università La Sapienza

Ingegneria del Software I

C# - caratteristiche

• Complessità del C++,1) “->” / “::” / “.” notazioni criptiche2) Particolari tipo di dato “wchar_t”, “__int64”

…3) Utilizzo degli interi come booleani, 4) problema del ‘==‘ e ‘=‘

• In C#,1) Notazione principale è il “.”.2) È stato introdotto il tipo bool per eliminare

confusioni

Page 13: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

13Università La Sapienza

Ingegneria del Software I

C# - caratteristiche

• In C# non ci sono puntatori.• La gestione della memoria è a

carico del garbage collector fornito con l’ambiente .NET

• Usando la modalità “unsafe” si può comunque accedere alla memoria direttamente.

Page 14: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

14Università La Sapienza

Ingegneria del Software I

C# - Object Orientation

• Incapsulamento, ereditarietà, polimorfismo

• I metodi della classi non sono virtual per default

• public, private, protected e internal

• L’ereditarietà permessa è singola

Page 15: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

15Università La Sapienza

Ingegneria del Software I

C# - Type Safety

• Le variabili non inizializzate non sono ammesse

• Il casting dei tipi ad UNSAFE non è permesso

• Data overflow, array index boundary checking

Page 16: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

16Università La Sapienza

Ingegneria del Software I

Un semplice esempio in C#

• hello world.

using System;class Hello { public static void Main(string[] args) {

Console.WriteLine(“hello, world”);

// print the command line argumentsfor (int i = 0; arg < args.Length; i++) Console.WriteLine(“arg [0],[1]”, i, args[i]);

}}

Page 17: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

17Università La Sapienza

Ingegneria del Software I

SDC (Self-Describing Components)

• I servizi forniti dal runtime sono metadata driven, questi metadati aggiungono informazioni agli eseguibili, come le definizioni di interfacce che prima specificate in IDL, TLB, proxy/stubs.

Page 18: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

18Università La Sapienza

Ingegneria del Software I

Web ServerWeb Server

Architettura dei Web Services

Web Service DeveloperWeb Service Developer

Web Service : ASMXWeb Service : ASMX

Web Application : ASMXWeb Application : ASMX

Author class, ASMX

Deploy Application

Web Application DeveloperWeb Application Developer

Request SCL Author Page that calls the Proxy

SDLSDL

Run Proxy Generator

ASPXASPX

C#, VBC#, VB

Web ServerWeb Server

ProxyProxy

Deploy Application

Web FormWeb Form

Call Methods

Deploy Application

Run Method

Page 19: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

19Università La Sapienza

Ingegneria del Software I

Web Service, ASMX

• Web service server salvato come “asmx” file.

• Richieste di web services basate su comunicazioni XML / SOAP.

• Oggetti e risorse accessibili via URL

Page 20: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

20Università La Sapienza

Ingegneria del Software I

Web ServerWeb Server

Web Service Development

Web Service DeveloperWeb Service Developer

Web Service : ASMXWeb Service : ASMX

Web Application : ASMXWeb Application : ASMX

Author class, ASMX

Deploy Application

Web Application DeveloperWeb Application Developer

Request SCL Author Page that calls the Proxy

SDLSDL

Run Proxy Generator

ASPXASPX

C#, VBC#, VB

Web ServerWeb Server

ProxyProxy

Deploy Application

Web FormWeb Form

Call Methods

Deploy Application

Run Method

Page 21: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

21Università La Sapienza

Ingegneria del Software I

1 Author Class, ASMX<%@ WebService Language="C#" Class=“MyService" %>

using System;using System.Web.Services;

public class MyService {

[WebMethod]public String MyServiceFunction1(String strParm1, String strParm2) {

...}

[WebMethod]public void MyServiceFunction2(Integer intParm) {

...}

}

Page 22: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

22Università La Sapienza

Ingegneria del Software I

Deploy Application

• Per implementare l’applicazione web va copiato il file ASMX nel web folder.

Page 23: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

23Università La Sapienza

Ingegneria del Software I

Web Application, ASPX

• Per utilizzare i web services va creato un “Proxy”.

• Proxies sono creati in DLL compilando il codice stub genrato dal proxy generator.

• Il proxy generator genera il codice stub dal SDL che è esportato dai web services.

Page 24: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

24Università La Sapienza

Ingegneria del Software I

Web ServerWeb Server

Web Application Development

Web Service DeveloperWeb Service Developer

Web Service : ASMXWeb Service : ASMX

Web Application : ASMXWeb Application : ASMX

Author class, ASMX

Deploy Application

Web Application DeveloperWeb Application Developer

Request SCL Author Page that calls the Proxy

SDLSDL

Run Proxy Generator

ASPXASPX

C#, VBC#, VB

Web ServerWeb Server

ProxyProxy

Deploy Application

Web FormWeb Form

Call Methods

Deploy Application

Run Method

Page 25: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

25Università La Sapienza

Ingegneria del Software I

Request SCL + Run Proxy Generator

• Creazione del codice del Proxy da SDL.

• Webserviceutil/c:proxy

/pa:http://hostname/MyService.asmx?SDL /l:Csharp

/n:MyServices

/c:proxy Crea codice del Proxy dal SDL/pa:URL Specifica URL per il SCL(SDL)/l:language Specifica il linguaggio sorgente/n:namespace Specifica il namespace del proxy

Page 26: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

26Università La Sapienza

Ingegneria del Software I

Deploy (Proxy) Application

• Compila il codice generato e copia il file DLL nel web folder per implementare il proxy.

• csc /out:..\bin\MyService.dll /t:library

/r:system.data.dll /r:system.web.services.dll

/r:system.xml.serialization.dll MyService.cs

Page 27: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

27Università La Sapienza

Ingegneria del Software I

Author ASPX<%@ Import Namespace="System.Web.UI.WebControls" %>

<%@ Import Namespace=“MyServices" %>

<HTML>

<HEAD>

<TITLE>My Service Page</TITLE>

<SCRIPT LANGUAGE="C#" RUNAT="SERVER">

MyService s = new MyService(); // my service

String strResult;

strResult = s.MyServiceFunction1(“Hello”, “World”);

s.MyServiceFunction2(12345);

...

Page 28: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

28Università La Sapienza

Ingegneria del Software I

Deploy (Web) Application

• Per implementare l’applicazione web va copiato il file ASPX nel web folder.

Page 29: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

29Università La Sapienza

Ingegneria del Software I

The innovative featureMyService.ASPX...<SCRIPT LANGUAGE="C#" RUNAT="SERVER">

Calendar c;SelectedDatesCollection dtSelectedPeriod;...c = CALENDAR;...dtSelectedPeriod = calendar.SelectedDates;...

</SCRIPT>...<ASP:CALENDAR id="CALENDAR" runat="server" ALIGN=LEFT

CellPadding="3" CellSpacing="1" DayNameFormat="FirstLetter"FirstDayOfWeek="Default" NextMonthText=">“...

/>

Page 30: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

30Università La Sapienza

Ingegneria del Software I

Servizio web scheduler

Page 31: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

31Università La Sapienza

Ingegneria del Software I

References[1] “Microsoft.NET”, http://www.microsoft.com/net/default.asp[2] “The simplest way to define .NET”, http://www.microsoft.com/net/defining.asp[3] “An Introduction to Microsoft Hailstorm”,

http://www.microsoft.com/net/hailstorm.asp[4] “Bill Gates’ Web Site – Speeches”,

http://www.microsoft.com/billgates/speeches/2001/03-19hailstorm.asp[5] “Microsoft Announces ‘Hailstorm’, a New Set of XML Web Services Designed …,

http://www.microsoft.com/presspass/features/2001/mar01/03-19hailstorm.asp[6] G. Lee, “Paradigm shift in software development environment, MS Visual

Studio.NET”, Microsoftware, pp. 202 ~ 213, Korea, Jan. 2001.[7] “Introduction to the Common Language Specification (CLS)”,

http://msdn.microsoft.com/library/dotnet/cpapndx/_cor_introduction_to_the_common_language_specification__cls_.htm

[8] “What is Common Language Specification?”, http://msdn.microsoft.com/library/dotnet/cpguide/cpconwhatiscommonlanguagespecification.htm

[9] “Overview of the Common Language Runtime”, http://msdn.microsoft.com/library/dotnet/cpapndx/_cor_overview_of_the__common_language_runtime.htm

Page 32: Università La Sapienza Ingegneria del Software I 1 Ingegneria del software I Seminario 2: Microsoft.NET.

32Università La Sapienza

Ingegneria del Software I

References[10] “Microsoft.NET in Retail and Hospitality”,

http://www.microsoft.com/technet/net/NETRetal.asp[11] “Microsoft.NET for Manufacturing: Extending the Enterprise Through Open

Protocols”, http://www.microsoft.com/technet/ecommerce/netmanu.asp[12] “Microsoft .NET Platform – What it is”, http://www.microsoft.com/ISN/IndOutlook_Trends/NET_Platform_what_it_is.asp[13] “Overview of Microsoft.NET”,

http://www.microsoft.com/ISN/IndOutlook_Trends/ms_net_overview.asp[14] “The Programmable Web”,

http://msdn.microsoft.com/msdnmag/issues/0900/webplatform/webplatform.asp[15] “Build Web Applications Faster and Easier Using Web Services and XML”,

http://msdn.microsoft.com/msdnmag/issues/0900/VSNET/VSNET.asp[16] “Sharp New Language : C# Offers the Power of C++ and Simplicity of Visual

Basic”, http://msdn.microsoft.com/msdnmag/issues/0900/csharp/csharp.asp[17] G. Kim, “The announcement of Hailstorm composed of XML web services”,

Microsoftware, p. 172, Korea, Apr. 2001.