View
1.329
Download
1
Category
Tags:
Preview:
DESCRIPTION
Presention I gave at the 2012 SC GMIS Developer Summit. Covers a wide range of .NET Developer Topics.
Citation preview
Developing with .NET
Frank La Vigne
Developer Evangelist
Microsoft
@tableteer | FrankLa@Microsoft.comwww.FranksWorld.com/blog
A Quick Word About MSDN
Not just downloads• Documentation• Articles• Sample Code• Specialty sites• ASP.NET• Silverlight.net• WindowsClient.net
• And much more!
The Future
Soon, Very Soon.
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
.NET Everywhere
Web Windows Cloud Phone Games Data
Write .NET Code in All of These Environments
.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
BASE CLASS LIBRARIES(BCL) IMPROVEMENTS IN .NET 4.X
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));
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;
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
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
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
EHANCEMENTS TO PROGRAMMING LANGUAGESIN .NET 4.X
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
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.
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
F#
• IDE support for F#• Interactive F# for prototyping code• Asynchronous constructs• Parallel constructs• Immutable data types
Web Client Development
But What About?
I <3 Silverlight!
You Can Use Them Both
• Blue Angels Web Site• http://blueangels.navy.mil
Looking Forward
Site Pinning
http://buildmypinnedsite.com/
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.
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
A Free Web Dev Tool
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
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
CHOICE IS GOOD
WHAT IS MVC?
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
ASP.NET MVC 101
Model(Data)
View(Presentation)
Controller(Input)
• What does MVC look like?
How MVC Works
Request
View
Controller
Response
ControllerRetrieves Model“Performs Work”
ViewVisually representsthe model
WHY SHOULD WE CARE ABOUT ASP.NET MVC IN PUBLIC SECTOR?
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
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.
Testing
• Enable fast, TDD-friendly development for creating sophisticated applications
• Separation of concerns makes for easier testing
Accessibility
• Uses the latest web standards.• Full control over markup makes creating
compliant sites easier
Performance
• No ViewState • Smaller HTML payload• Faster downloads
• HTML5• Easy to implement eye catching graphics that leverage GPU
acceleration with IE9 and IE10
DEMOCreating an ASP.NET MVC 3 Project
Razor
@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
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):
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
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
SILVERLIGHT & WPF DEVELOPMENT
Two Platforms
Similar But Different
WPF
Silverlight
2 Platforms Powered By XAML
Two Core Technologies
One Common Language
XAML Powers It All
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.
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>
Results
Most Devs Reaction to Blend
Demo
Mobile
1 Platform. 2 Choices.
For the purposes of this talk, we’ll focus on Silverlight.
What is Metro?
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.
Desktop?
Metro Resources
• http://frnk.us/8GreatTraitsOfMetroApps• http://frnk.us/MetroTutorial
DEMOCreating a Windows Phone App
Marketplace Sample
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
Code-First in EF 4.1
ExistingDatabase
GeneratedEntity Data
Model
DatabaseFirst
Entity DataModel
GeneratedDatabase
ModelFirst
DEMO
Useful Resources
Phone SDK Download
http://bit.ly/WinPhoneSDKDownload Web Matrix
http://bit.ly/WhatIsWebMatrix Azure
http://bit.ly/FreeAzure90DayTrial
http://bit.ly/DownloadAzureSDK
Recommended