1 / 20

.NET Whirlwind Intro for Rice

.NET Whirlwind Intro for Rice. Michael Stuart Sr. Consultant mstuart@microsoft.com Will Rice class of 1991. Chris Wafer Lowly Consultant cwafer@microsoft.com Jones class of 2000. Outline. Who are we? (not an existential conundrum) What is .NET? Marketing mantra vs. reality

ulysses
Télécharger la présentation

.NET Whirlwind Intro for Rice

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. .NET Whirlwind Introfor Rice Michael StuartSr. Consultantmstuart@microsoft.comWill Rice class of 1991 Chris WaferLowly Consultantcwafer@microsoft.comJones class of 2000

  2. Outline • Who are we? (not an existential conundrum) • What is .NET? • Marketing mantra vs. reality • Platform…for web services • Tools—Visual Studio • 2002 vs. 2003, RTM vs. Everett vs. Whidbey • Mongo debugging, templates, visual designers • .NET Framework Overview • CLR, CTS, CLI • OO, JIT, GC • Practical development with .NET • OO, design patterns • Mobile development • .NET CF (Compact Framework) • Web Services • Questions

  3. Who are we? • Chris— • Recent Rice grad, real CS not flaky other pseudo-science • Consultant at Microsoft in South Region • Specializes in .NET development • Fingers possessed by l33t hax0rs of yore • Thinks M3 is faster than M-Coupe, too young to know better • Michael— • Lovable but slightly addled uncle-type • Old Rice grad—Biochem/Bio+PoliSci, M.D. • Hacker of old, cut teeth in 6502 Assembler • Specialized in .NET dev • Currently working with PAG team on patterns

  4. What is .NET? • Marketing mantra vs. reality • .NET Framework—Visual Studio, actual runtime, languages, web services are _really_ “.NET” • “.NET Servers”—are .NET enabled but not necessarily written in .NET (CS2k, BizTalk…) • Platform…for web services • Much more to-the-point: .NET is a platform for Web Services • Other • Loosely-coupled programming model • New paradigm for Microsoft-based developers • Much easier to write good code • Focus on logic, not plumbing—we’ll wear the plumber jeans 

  5. Tools • 2002 vs. 2003, RTM vs. Everett vs. Whidbey • VS.NET—complete tool for developing .NET (and old-school) software • Encompasses all languages—C#, VB.NET, J#, 20+ others • RTM—Framework v. 1.0.3705 • Everett—currently beta, v. 1.1.4322 • Whidbey—future, big changes (generics, built-in patterns, etc.) • Mongo debugging, templates, visual designers • Debugging—over the river, through the woods… • Templates—strong future • Designers—beloved RAD tools, beefier underpinnings now

  6. .NET Framework Overview • CLR, CTS, CLI • OO, JIT, GC

  7. .NET Framework Overview 2Infrastructure for the .NET Platform • Common Language Runtime • Manages running code • Verifies type safety • Provides garbage collection, error handling, threading • Security • Provides common type system • Provides access to system resources • Native API, COM interop, etc. • A collection of unified classes

  8. .NET Framework Overview 3Win32 and the .NET Framework Unified Class libraries Unifies Programming models across languages Factored for extensibility Designed for tools C# Visual J#... Visual Basic .NET Enterprise Services ASP.NET ADO.NET Enterprise Services The services required for mission critical applications: Transactions, Messaging, Partitions, Object Pooling and Events COM: Not Dead Yet CLR XML and Data Access ADO .NET interfaces any database, loosely coupled data access and native XML data format; leverages the huge library of ODBC OLE DB drivers Active Directory MSMQ COM+ IIS WMI Win32 CLR Executes code, maintains security, handles component “plumbing” and dependencies XML Web Services and Scripting High-productivity environmentfor building and operating XML Web services

  9. .NET Framework Overview 3CLR Duties • Manages running code • Threading • Memory management / GC • JIT to native • COM Interop • Security, type safety, bounds checks, assembly loading, remoting, etc. (all runtime stuff) • Fine-grained evidence-based security • Code access security • IL can be verified to guarantee type safety • No unsafe casts, no un-initialized variables and no out-of-bounds array indexing • Role-based security • Integrated with underlying OS

  10. Code Source Code Language Compiler MSIL Metadata Execution Native Code JIT Compiler .NET Framework Overview 4Compilation and Execution ILDASM! IL_000c: br.s IL_002a IL_000e: ldloc.1 IL_000f: callvirt instance object [mscorlib]System.Collections.IEnumerator::get_Current() IL_0014: castclass [mscorlib]System.String IL_0019: stloc.0 IL_001a: ldstr "Flea's name : " Compilation Before execution (ngen) or the first time each method is called

  11. .NET Framework Overview 4Simplified Development • Eliminates COM plumbing • No more … • Registration • GUIDs • .IDL files • HRESULTs • IUnknown • AddRef/Release • CoCreateInstance =>self describing components =>hierarchical namespaces =>source code to metadata =>structured exceptions =>root object class =>garbage collector =>”new” operator

  12. Practical Development with .NET • Demo—how to set up quickie web service (asmx) • Demo—web-service-based Forth calculator • Demo—Interfaces and Abstracts • Demo—Virtual vs. Non-Virtual calls • Debugging down to the metal: • Memory view • Register view • X86 ASM view • Demo—delegates and events • Demo—how to screw up Boxing/Unboxing • Demo—UIP “pet project” • Demo—database access application (??)

  13. Practical Development with .NET • Demo—how to set up quickie web service (asmx) • Basic web service requires ASMX file + code • ASP.NET HttpModule hooks up ASMX to code • Compiles and JIT’s code • Generates WSDL dynamically (SOAP contract) • Core syntax: • <%@ WebService Language="c#" Class="Calculator " %> • [WebMethod] • (try THAT in J2EE  )

  14. Practical Development with .NET • Demo—web-service-based Forth calculator • Now consume the calculator web service we made • Uses stack-based calc • Uses Compact Framework • Accesses web service from Pocket PC device • Note use of derived stack— • IN FUTURE FRAMEWORK, GENERICS will do this 

  15. Practical Development with .NET • Demo—Interfaces and Abstracts • .NET supports • Multiple interface implementation • Single inheritance—NO multiple inheritance • Abstract base class • Base functionality • Not instantiable • Good use: “is a kind of”, abstract entity meaningless— • Mammal abstract base—but there’s no plain “mammal” animal • Lion : Mammal—concrete derivative has meaning but borrows basic functionality such as sleep, heartbeat from abstract • Interface implementation • Heavy use of “marker” interfaces in .NET (IDisposable) • Provides strict contractual obligation • No base functionality

  16. Practical Development with .NET • Demo—Virtual vs. Non-Virtual calls • Non-default virtual in .NET • Public void Foo() in class A • Public new void Foo() in Class B : A • B.Foo does B.Foo; ((A)B).Foo does A.Foo • Public virtual void Foo() in class C • Public override void Foo() in Class D : C • D.Foo does D.Foo; ((C)D).Foo STILL does D.Foo • Be careful of deep inheritance chains • If middle of chain does “new”, THAT is where it stops! • UNLESS you play games with versioning • .NET avoids “Base Class Fragility” with versioning!

  17. Practical Development with .NET • Demo—delegates and events • Fundamental Rule #1: • “A Delegate is a Type-Safe Function Pointer!” • James Gosling (father of Java) calls Anders Heljsberg “Mr. Function Pointers” • Anders is too polite to respond  • Delegate syntax: • public delegate void DoneCookingDelegate(); • Delegates are always multi-cast; you can chain them up • Delegates can be declared anywhere; if they’re accessible they’re good • Delegates point to a concrete endpoint that matches signatures • EVENTS in .NET are special-case delegates

  18. Practical Development with .NET • Demo—how to screw up Boxing/Unboxing • How is .NET so FAST? • Singly-rooted hierarchy; • ALL objects derive from System.Object—ints, strings, doubles, even kids with chickenpox • An Int32 is an object if you treat it like one, otherwise it’s stack-allocated • Value Types vs. Reference Types • Value types go on stack—int, double, long, struct, double, decimal, uint, etc. • Reference types are officially objects all the time and go on HEAP • .NET can BOX—convert value type to ref type • .NET can UNBOX—convert ref to value • Be Careful—boxing implicit, unboxing explicit

  19. QUESTIONS???

  20. Thank you all Very Much!Michael Stuart—mstuart@microsoft.comChris Wafer—cwafer@microsoft.com

More Related