380 likes | 481 Views
Introduction to .NET and Eiffel for .NET. Karine Arnout Chair of Software Engineering – Bertrand Meyer ETH Zurich, Switzerland Karine.Arnout@inf.ethz.ch. Presentation outline. What is .NET? Eiffel for .NET. Presentation outline. What is .NET? Eiffel for .NET. What .NET is not?.
E N D
Introduction to .NET and Eiffel for .NET Karine Arnout Chair of Software Engineering – Bertrand Meyer ETH Zurich, Switzerland Karine.Arnout@inf.ethz.ch ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Presentation outline • What is .NET? • Eiffel for .NET ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Presentation outline • What is .NET? • Eiffel for .NET ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
What .NET is not? • NOT a programming language: • “C# is not .NET and .NET is not C#”. • NOT an operating system (yet). ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
What .NET is… • An open-language platform for enterprise and Web development. ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
The scope of .NET • .NET addresses almost everyone: • The general public • New user-friendly services • Businesses • Help improve “B2B” relationships. • Developers • Security • Programming-language interoperability • Component-based development • Versioning • Memory management ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
The .NET architecture Web services UDDI, WSDL, Passport Openinterchange formats XML & SOAP Frameworks &libraries ASP.NET, Windows Forms, Remoting… C#, Visual Basic.Net, Managed C++, Cobol, Eiffel for .NET… Specificlanguagecompilers Languageinteroperability Common Language Specification (CLS) Development environment Visual Studio.Net Compilation,execution… Common Language Runtime (CLR) Underlying platform Hardware, Operating system, database system ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
The Common Language Runtime • Basic set of mechanisms to execute .NET programs. • Virtual machine based on internal code: CIL. • CIL: not interpreted but “jitted” to native platform. • Built-in security mechanisms. ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
The .NET execution model ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
.NET specific vocabulary • Managed code: Native code for the target platform, intended to run under the control and with the help of the CLR. • Ex: C#, Eiffel for .NET, Managed C++ • Unmanaged code: Native code that doesn’t rely on the CLR. • Ex: “Classic” Eiffel, Unmanaged C++ ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
The assembly • Compiled form of a set of classes • The .NET unit of reuse(“.exe” or “.dll”) • May be shared or private. • Notion of Global Assembly Cache • Contains: • CIL code (not binary code) • Metadata (interface information) • Can be viewed with ILDasm. ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
The Global Assembly Cache ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
.NET libraries (1/2) ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
.NET libraries (2/2) → See the Reference documentation for more information. ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Towards new services… ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Successful registration ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Passing erroneous data ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
About this demo… • Some of what this demo illustrates: • ASP.NET (Active Server Pages .NET) • Server-side mechanisms, server controls • Debugging Web applications like traditional ones • Our first C# example • Multi-language development(C#, Eiffel for .NET) ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Multi-language support C++ C# Eiffel ... Framework Windows ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Full interoperability • Cross-language… • Inheritance • Classes can inherit from each other, regardless of language of origin. • No need for wrappers • No IDL • Debugging sessions • In Visual Studio.Net • Exceptions ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Full interoperability: the price to pay… • Must conform to the .NET object model(VOS, Virtual Object System): • The type system • Object-oriented principles (type, inheritance) • Too much for some (non-O-O languages) • Too little for some: multiple inheritance (Eiffel) • Difficult features: overloading • Must observe the Common Language Specification (CLS) • Set of rules – more restrictive than the .NET object model – to determine compatibility. • Now a standard: ECMA, ISO. ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Type Value Reference Pointer Class Interface User-defined Built-in Structure-equivalent Name-equivalent Integertype Enums Unmanaged Managed Boxed value type Array Function Floatingtype Delegate Boxed enum Typedref The .NET type system ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Presentation outline • What is .NET? • Eiffel for .NET ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Design by Contract on .NET • Like Eiffel, Eiffel for .NET directly enforces Design by Contract, which addresses: • Correctness • Documentation • Debugging and testing • Inheritance control • Management • Eiffel for .NET is the sole language on .NET to natively support contracts. ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Eiffel for .NET • Full implementation of Eiffel on .NET: • Design by Contract • Seamlessness of software development • Multiple inheritance • Genericity… • Large set of libraries: • Eiffel libraries + .NET libraries • Directly available in EiffelStudio • Integrated into Visual Studio.NET: Eiffel ENViSioN!™ • Smart editor • Project clusters browsing… ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
ISE EiffelStudio ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Multiple inheritance and genericity… • … Or how to map non-CLS compliantmechanisms on .NET while preserving languageinteroperability? ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Create.A Create.B Create.C A B Impl.A Impl.B C Impl.C Multiple inheritance on .NET • How Eiffel for .NET does it: • Taking full advantage of interfaces and namespaces. Shadowing classes with interfaces. ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
“Hello World!” with Eiffel for .NET class HELLO_WORLD create make feature {NONE} -- Initialization makeis -- PrintHello_world_message. do io.put_string (Hello_world_message) end feature -- Constant Hello_world_message:STRINGis“Hello World!” --Hello World! message end ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Full interoperability on .NET (1/4) • With C#: public class HelloWorld1 { public static void Main() { HelloWorld sample; sample = Create.HelloWorld.Make(); } } ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Full interoperability on .NET (2/4) • With VB.NET: Public Class HelloWorld1 Public Sub Main () Dim sample as HelloWorld sample = Create.HelloWorld.Make() End Sub End Class ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Full interoperability on .NET (3/4) • With C#: using System; public class HelloWorld2: Impl.HelloWorld { public static void Main() { HelloWorld2 h2; h2 = new HelloWorld2(); Console.WriteLine (h2.HelloWorldMessage()); } } ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Full interoperability on .NET (4/4) • With VB.NET: Imports System Public Class HelloWorld2 Inherits Impl.HelloWorld Public Shared Sub Main() Dim h2 as HelloWorld2 h2 = new HelloWorld2() Console.WriteLine (h2.HelloWorldMessage()) End Sub End Class ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
C#: A step forward • Smooth transition from Java to .NET • Similar syntax • A step forward • Strong type system, event-handling, … • Not the silver bullet • Sometimes too complicated (delegates) • No native support for contracts • No genericity • No multiple inheritance Eiffel for .NET is definitely better! ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Research work • Extraction of contracts from .NET libraries: • Study of the .NET Collections library • Development of a CIL parser to extract preconditions automatically • Contract Wizard to add contracts to a .NET assembly a posteriori ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
References: About .NET and Eiffel for .NET • Karine Arnout: Introduction to Eiffel for .NET. CoDe Magazine, Sept / Oct 2002. • Bertrand Meyer: The .NET Training Course. Prentice Hall, 2001. • Bertrand Meyer, Raphaël Simon, Emmanuel Stapf: Instant .NET. Prentice Hall, 2002 (in preparation). • Microsoft: .NET Reference documentation. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/cpref_start.asp. • .NET Experts: http://www.dotnetexperts.com • Raphaël Simon, Emmanuel Stapf, and Bertrand Meyer. “Full Eiffel on .NET”. MSDN, July 2002. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/pdc_eiffel.asp. ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
References: About contract extraction • Karine Arnout, and Raphaël Simon. “The .NET Contract Wizard: Adding Design by Contract to languages other than Eiffel”. TOOLS 39. IEEE Computer Society, July 2001, p 14-23. • Karine Arnout. “Extracting implicit contracts from .NET libraries”, GCSE Young Researchers Workshop, NET.OBJECT DAYS, 7-10 October 2002, Erfurt, Germany. • Karine Arnout. “Extracting Implicit Contracts from .NET Libraries”, OOPSLA 2002 (Poster session), Seattle USA, 4-8 November 2002, OOPSLA'02 Companion, ACM, p 104-105. • Karine Arnout, and Bertrand Meyer. “Finding Implicit Contracts in .NET Components”, to appear in Formal Methods for Components and Objects (FMCO), eds. Frank de Boer et al., Springer-Verlag, 2003. ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003
Any Questions? Karine.Arnout@inf.ethz.ch http://se.inf.ethz.ch/people/arnout ECOOP, .NET: The programmer's perspective - Darmstadt, July 2003