intro to .net for government developers
DESCRIPTION
Presention I gave at the 2012 SC GMIS Developer Summit. Covers a wide range of .NET Developer Topics.TRANSCRIPT
![Page 1: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/1.jpg)
Developing with .NET
Frank La Vigne
Developer Evangelist
Microsoft
@tableteer | [email protected]/blog
![Page 2: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/2.jpg)
A Quick Word About MSDN
Not just downloads• Documentation• Articles• Sample Code• Specialty sites• ASP.NET• Silverlight.net• WindowsClient.net
• And much more!
![Page 3: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/3.jpg)
The Future
![Page 4: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/4.jpg)
Soon, Very Soon.
![Page 5: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/5.jpg)
Tools of the Trade
• Visual Studio 2010• Multiple versions with multiple price points
• Expression Blend
Nice to have tools• F12 Dev Tools• Fiddler• Silverlight Spy
![Page 6: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/6.jpg)
![Page 7: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/7.jpg)
.NET Everywhere
Web Windows Cloud Phone Games Data
Write .NET Code in All of These Environments
![Page 8: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/8.jpg)
.NET Architecture
.NET Framework Architecture
Base Class Libraries
Common Language RuntimeJIT & NGEN
Garbage Collector
Security Model
Exception Handling
Loader & Binder
WPFWin
FormsDLR ASP.NET WCF
And more!
LINQ
![Page 9: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/9.jpg)
BASE CLASS LIBRARIES(BCL) IMPROVEMENTS IN .NET 4.X
![Page 10: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/10.jpg)
Task Parallel Library (TPL)
Set of public types and APIs System.Threading System.Threading.Tasks
// Sequentialforeach (var item in sourceCollection) { Process(item); }
// ParallelParallel.ForEach (sourceCollection, item => Process(item));
![Page 11: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/11.jpg)
Parallel LINQ (PLINQ)
Implements the full set of LINQ standard query operators Extension methods for the IParallelEnumerable interface Additional operators for parallel operations
from n in names.AsParallel().WithDegreeOfParallelism(ProcessorsToUse.Value)where
n.Name.Equals(queryInfo.Name, StringComparison.InvariantCultureIgnoreCase) &&
n.State == queryInfo.State && n.Year >= yearStart && n.Year <= yearEnd
orderby n.Year ascending
select n;
![Page 12: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/12.jpg)
Design By Contract
• System.Diagnostics.Contracts• Code Contracts introduce a way to specify contractual
information that is not represented by a method or type’s signature alone
• Scenarios for using contracts include:• Perform static bug finding, which enables some bugs to be found
without executing the code• Create guidance for automated testing tools to enhance test
coverage• Create a standard notation for code behavior, which provides
more information for documentation
![Page 13: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/13.jpg)
Data Types
• BigInteger• Immutable type that represents an arbitrarily large integer whose
value in theory has no upper or lower bounds
• SortedSet<T>• Provides a self-balancing tree that maintains data in sorted order
after insertions, deletions, and searches
![Page 14: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/14.jpg)
I/O
• Memory-Mapped File• Used to edit very large files and to create shared memory
for inter-process communication
• Stream.CopyTo• Allows you to copy the contents of one stream into another
![Page 15: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/15.jpg)
EHANCEMENTS TO PROGRAMMING LANGUAGESIN .NET 4.X
![Page 16: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/16.jpg)
Visual Basic
• Auto-Implemented Properties• Shortened syntax that enables you to quickly specify a property
of a class without having to write code
• Collection Initializer• Shortened syntax that enables you to create a collection and
populate it with an initial set of values
• Implicit Line Continuation• Enables you to continue a statement on the next consecutive line
without using the underscore character
![Page 17: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/17.jpg)
C#
• Dynamic Type• Operations that contain expressions of type dynamic are not
resolved or type ch`ecked by the compiler. The compiler packages together information about the operation, and that information is later used to evaluate the operation at run time
• Optional and Named Parameters• Named arguments enable you to specify an argument for a
particular parameter by associating the argument with the parameter's name rather than with the parameter's position in the parameter list.
• Optional arguments enable you to omit arguments for some parameters. Both techniques can be used with methods, indexers, constructors, and delegates.
![Page 18: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/18.jpg)
C++
• You can configure restart manager to autosave documents and restart your application after it exits unexpectedly
• Lambda expressions are available in C++• The new CTaskDialog replaces the standard Windows
message box and adds functionality to display and gather more information
![Page 19: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/19.jpg)
F#
• IDE support for F#• Interactive F# for prototyping code• Asynchronous constructs• Parallel constructs• Immutable data types
![Page 20: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/20.jpg)
Web Client Development
![Page 21: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/21.jpg)
But What About?
![Page 22: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/22.jpg)
I <3 Silverlight!
![Page 23: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/23.jpg)
You Can Use Them Both
• Blue Angels Web Site• http://blueangels.navy.mil
![Page 24: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/24.jpg)
Looking Forward
![Page 25: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/25.jpg)
Site Pinning
http://buildmypinnedsite.com/
![Page 26: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/26.jpg)
The Microsoft Web Platform
Web
Pla
tfor
m I
nsta
ller Ajax Control Toolkit & jQuery
ASP.NET
ADO.NET Entity Framework
SQL Server
IIS
The Microsoft Web Platform combines a rich and powerful web application framework with a supporting cast of tools, servers, technologies and applications for creating, designing, developing and delivering web solutions.
![Page 27: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/27.jpg)
Today’s Web Developers
I <3 Web Apps.
I just need a tool that
makes them easier to
configure, customize and
publish them
I want to build web sites myself with an
easy to learn tool and framework
I’m a professional software developer and I build complex, large scale web sites with a
team of developers
![Page 28: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/28.jpg)
A Free Web Dev Tool
![Page 29: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/29.jpg)
ASP.NET: A Framework For All
Caching Modules
HandlersIntrinsics
Pages Controls
Globalization
Profile
Master Pages
MembershipRoles
Etc.
ASP.NET Core
ASP.NET Web Forms
ASP.NET MVC
ASP.NET Web Pages
Web Forms View Engine Razor View Engine
Visual Studio 2010 WebMatrix
![Page 30: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/30.jpg)
ASP.NET 4 Webforms
• Ability to set meta tags• More control over view state• Added and Updated browser definition files• ASP.NET Routing• The ability to persist selected rows in data controls• More control over rendered HTML in the FormView and
ListView controls• Filtering support for data source controls
![Page 31: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/31.jpg)
CHOICE IS GOOD
![Page 32: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/32.jpg)
WHAT IS MVC?
![Page 33: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/33.jpg)
Model-View-Controller (MVC)
• Huge investment from Microsoft• Alternative to WebForms• Modular Architecture• MVC 3.0 now available• MVC 4 in Developer Preview stage
• Razor Syntax• MVC 3.0 Tooling Updated
April 2011
![Page 34: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/34.jpg)
ASP.NET MVC 101
Model(Data)
View(Presentation)
Controller(Input)
![Page 35: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/35.jpg)
• What does MVC look like?
How MVC Works
Request
View
Controller
Response
ControllerRetrieves Model“Performs Work”
ViewVisually representsthe model
![Page 36: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/36.jpg)
WHY SHOULD WE CARE ABOUT ASP.NET MVC IN PUBLIC SECTOR?
![Page 37: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/37.jpg)
More Web Savvy Citizens
• Users disdain “Ugly” URLs• http://answers.usa.gov/system/selfservice.controller?
CONFIGURATION=1000&PARTITION_ID=1&CMD=VIEW_ARTICLE&ARTICLE_ID=11951&USERTYPE=1&LANGUAGE=en&COUNTRY=USvshttp://www.whitehouse.gov/briefing-room/speeches-and-remarks
• Search Engine Optimization (SEO)• Discoverability
![Page 38: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/38.jpg)
Developer Productivity
• Powerful, patterns-based way to build dynamic websites • Enables a clean separation of concerns• Gives you full control over markup for enjoyable, agile
development.
![Page 39: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/39.jpg)
Testing
• Enable fast, TDD-friendly development for creating sophisticated applications
• Separation of concerns makes for easier testing
![Page 40: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/40.jpg)
Accessibility
• Uses the latest web standards.• Full control over markup makes creating
compliant sites easier
![Page 41: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/41.jpg)
Performance
• No ViewState • Smaller HTML payload• Faster downloads
• HTML5• Easy to implement eye catching graphics that leverage GPU
acceleration with IE9 and IE10
![Page 42: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/42.jpg)
DEMOCreating an ASP.NET MVC 3 Project
![Page 43: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/43.jpg)
Razor
![Page 44: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/44.jpg)
@if (You.Understand(Razor)) {
<div>Hooray!</div>
}• New, Simplified View Engine• Write fewer lines of code• More natural mix code and markup• Helpers save you time• Compatible with ASP.NET Web Pages in WebMatrix• http://bit.ly/WhatIsWebMatrix
Razor Syntax
![Page 45: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/45.jpg)
Razor: a Cut Above the Rest
<ul> <% for (int i = 0; i < 10; i++) { %> <li><% =i %></li> <% } %></ul>
<ul> @for (int i = 0; i < 10; i++) { <li>@i</li> }</ul>
Razor (2 markup transitions):
Web Forms (6 markup transitions):
<ul> <?php for ($i = 0; $i < 10; $i++) { echo("<li>$i</li>"); } ?></ul>
PHP(2 markup transitions
& an echo):
![Page 46: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/46.jpg)
Easier Code to Markup Transitions
@{ var name = “John Doe”; <div> Your name: @name </div>}
@{ var name = “John Doe”; @: Your name: @name}
Option 3:Single line of output
in markup
Option 1:HTML Block
@{ var name = “John Doe”; <text> Your name: @name </text>}
Option 2:Text Block
![Page 47: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/47.jpg)
Code Comments in Razor
@* <div> Hello World </div>*@
@* @{ var name = "John Doe"; @name }*@
Option 3:Both
Option 1:Markup
@{ //var name = "John Doe”; //@name}
Option 2:Code
![Page 48: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/48.jpg)
SILVERLIGHT & WPF DEVELOPMENT
![Page 49: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/49.jpg)
Two Platforms
![Page 50: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/50.jpg)
Similar But Different
WPF
Silverlight
![Page 51: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/51.jpg)
2 Platforms Powered By XAML
Two Core Technologies
One Common Language
XAML Powers It All
![Page 52: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/52.jpg)
Intro to XAML
• Markup language derived from XML• XML serialization of CLR objects• Markup files have code-behind files• Could be C# or VB.NET
• Conceptually similar to ASP.NET • X stands for Extensible• Data Binding• Styles• Templates
Relax, it’s just XML.
![Page 53: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/53.jpg)
What Does XAML Look Like?
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <Grid>
<Button>Click Me!</Button> </Grid></Window>
![Page 54: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/54.jpg)
Results
![Page 55: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/55.jpg)
Most Devs Reaction to Blend
![Page 56: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/56.jpg)
Demo
![Page 57: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/57.jpg)
Mobile
![Page 58: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/58.jpg)
1 Platform. 2 Choices.
For the purposes of this talk, we’ll focus on Silverlight.
![Page 59: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/59.jpg)
What is Metro?
![Page 60: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/60.jpg)
![Page 61: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/61.jpg)
ETRO
METRO IS OUR DESIGN LANGUAGE. WE CALL IT METRO BECAUSE IT’S MODERN AND CLEAN. IT’S FAST AND IN MOTION. IT’S ABOUT CONTENT AND TYPOGRAPHY. AND IT’S ENTIRELY AUTHENTIC.
![Page 62: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/62.jpg)
Desktop?
![Page 63: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/63.jpg)
Metro Resources
• http://frnk.us/8GreatTraitsOfMetroApps• http://frnk.us/MetroTutorial
![Page 64: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/64.jpg)
DEMOCreating a Windows Phone App
![Page 65: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/65.jpg)
Marketplace Sample
![Page 66: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/66.jpg)
What is the Entity Framework?
• Creates Entity Model from Database• Helpful in creating RESTful Services• Exposes Database as Classes/Methods• Works with any Database• Useful in MVC, Dynamic Data Models
![Page 67: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/67.jpg)
Code-First in EF 4.1
ExistingDatabase
GeneratedEntity Data
Model
DatabaseFirst
Entity DataModel
GeneratedDatabase
ModelFirst
![Page 68: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/68.jpg)
DEMO
![Page 69: Intro to .NET for Government Developers](https://reader038.vdocument.in/reader038/viewer/2022103013/546b15cdaf795902048b4d55/html5/thumbnails/69.jpg)
Useful Resources
Phone SDK Download
http://bit.ly/WinPhoneSDKDownload Web Matrix
http://bit.ly/WhatIsWebMatrix Azure
http://bit.ly/FreeAzure90DayTrial
http://bit.ly/DownloadAzureSDK