Developing i phone, android and windows phone 7 applications with c#
-
Upload
marcel-de-vries -
Category
Technology
-
view
404 -
download
3
description
Transcript of Developing i phone, android and windows phone 7 applications with c#
Developing iPhone, Android and Windows Phone 7 applications with C#
Roy CornelissenIT Architect,Info Support
Willem MeintsDeveloper,Info Support
Roy CornelissenIT ArchitectInfo Support
Willem MeintsDeveloperInfo Support
Marcel de VriesTechnology ManagerInfo Support
Patterns ProofAgenda
Myths ALM
Setting the context
Windows PhoneVisual Studio, XAML and C#
iOSMonoDevelop, MonoTouch and C#
AndroidVisual Studio, Mono for Android and C#C#
Myth Busters
Common misconceptions
Myth: Apps built with C# are not native
C / C++Different CPU architectures
What is the meaning of “native”?• Different interpretations of “native”
Java
Objective-CC / C++
C# / Silverlight 3+
What is the meaning of “native”?
• Native = use the frameworks and libraries of the OS, regardless of the language or tools• Native = User experience 100% aligned with default OS device experience
DemoKnowledge Events app
3 native flavors
App Logic
Vendor tools “Magic Box” Hybrid
XCodeObjective-
C
WP7 Silverligh
tC#
Android SDKJava
Appcelerator Titanium
JavaScript > Native
PhoneGapHTML5 / CSS /
JS
Adobe AIRActionScript
AntennaRapid
Scripting Language
Service2Media
Lua
C#
Xamarin
MonoTouch
WP7 Silverlig
ht XamarinMono for Android
RhodesRuby + HTML
Sybase Unwired
“4GL” code gen Shared
language
Myth: Applications written with Mono are slow
Demo: Mandelbrot comparison
Text/Icon/PicMonoTouch
Objective-CText/Icon/Pic
Benoit Mandelbrot
Comparison Mono & Objective-C / Java
Speed upyour app
Develop wisely!
1.0
1.0
Application startup
Compute intensive
Service calls
UI interaction
Perceived performanceYes there is overheadNative-to-Managed causes overheadMono has a garbage collectorCPU-intensive: use LLVM compiler
But it’s no problemMost of us don’t build real time 3D gfx
Make the app feel fastKeep download size smallCut startup time by offloading tasks ASAPUse background tasks & activity indicators
…is in the eye of the beholder
Performance…
Even game developers choose Mono!
Delta engine
Myth: Mono cannot access all device capabilities
You can access all device capabilities!• For each platform there is a set of namespaces that
enable full device accessiOS
MonoTouch.CoreLocationMonoTouch.CoreMotionMonoTouch.AVFoundationMonoTouch.AddressBookMonoTouch.EventKit…
Android: Android.Hardware.SensorAndroid.LocationAndroid.BluetoothAndroid.Nfc…
Windows Phone: Microsoft.Devices.Sensors.GyroscopeMicrosoft.Devices.Sensors.AccelerometerMicrosoft.Devices.Sensors.CompassMicrosoft.Devices.Sensors.Motion…
Use device abstractions!
Myth: Code Sharing percentage between apps is very low because of the different implementations per device
Code Sharing
Reusable20%
Shared app logic20%Windows8
13%
iOS18%
WP712%
Android16%
Shared
65%
Specific35%
Per App
As long as you do proper design
Myth: You do not have to know the different devices to build apps for all different platforms
Roy Cornelissen
Willem Meints
Marcel de Vries
Application Lifecycle Management
Managing cross platform development
Cross device solution setup
Same directory structure used by all solutions
• Shared implementation project
• Include files your project needs
• Exclude files that are device specific
Cross platform version control• Use TFS in the cloud• Use Local Workspaces• SVN model of Edit, Merge, check-in• No need to check out before edit
• Use Team Explorer Everywhere for Mac OS
• Added bonus: full support for Work Items, Build, etc.
Architecture & Design Patterns
How to maximize reuse between platforms
Define architecture for reuse
Define architecture for reuse
Services
Model
ControllerViewModel
Etc.
GPS
Storage
Motion sensors
View
Shared?
BridgeShared Platform specific
Services• What technology do you use to access data?• Should we use REST/WebApi?• Lot of hand coding since there is no standard way to generate
proxies• Should we do SOAP?• Good option, also provides out of the box support in the tools for
proxy generation• Proxy generation with SL tools, so we have full shared code base
cross stacks
• Use RIA services as back-end• Adds productivity for back-end and flexibility in endpoints• SOAP, JSON, OData
Callback pattern
Shared Controller
UIViewController
XAML View Activity
Web Services
SF
SF
SF
Model
GetActualEvents (Action<object> OnSuccess,
Action<Exception> OnFail)
PropertyChanged(“Events”);
public void OnFailed(Exception e){ // Do something with error}
public void OnSuccess(object data){ // Do something with data // Notify user}
Device Abstraction Patterns
The proof of the pudding is in the eating…
DemoBuilding an Event app
Lessons learned• Android == Wild Wild West of mobile• Test ALWAYS on MULTIPLE devices!• Mono Release cycle only small lag with
vendor tools• UX design essential for apps• Good design up front of the app essential for
code sharing• First attempt 10% code share • Now we achieve 70-80% code sharing!
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Roy Cornelissen@roycornelissen
Willem Meints@wmeints
Marcel de Vries@marcelv