Tuesday, December 17, 2013

Take Advantage of iOS 7's New Features

On Sept. 18, Apple formally began distributing iOS 7 to users. Within one month, iOS 7 was running on 69.3 percent of iOS devices, according to app monitoring company Fiksu. On Sept. 20, Apple began selling the new iPhone 5s and 5c. While excitement surrounds the release of any new operating system, Apple creates additional excitement for developers, due to the rapid uptake of each new version of iOS.
With iOS 7, Apple has provided a number of new features worth getting to know. Since this column is called "Cross-Platform C#," the question of the length of time it takes Xamarin to provide support for new features comes up frequently. There's good news on that front, because Xamarin has provided same-day support for the latest version of iOS. This article will take a look at some of these new iOS features

Monday, December 16, 2013

Building Native User Interfaces is the Right Way To Build Cross Platform Style Apps

I hear a few developers getting down on Xamarin because they are required to:
  1. Create different projects for the various mobile platforms that they want to target.
  2. Learn the particulars of a given platform, or as I term them, the “isms.”
Interestingly, these are not negatives to going with a Xamarin style cross platform solution; these are most definitely positives in their style of solution.  Wait, how can this be?  Developers have been training to think that sharing as much code as possible (including the UI) is a good thing.  In this blog post, I’ll try to explain the issues of cross platform development, what users want (yes, I do tend to do crazy things like talk to users), the problems in cross platform development, and finally why presenting the user with a native solution is just plain better than a mobile web based solution.
What Users Want
Users want solutions to their problems.  It is pretty simple.  Solve a user problem, don’t create more problems, help the business cut costs, be a net positive in an organization, add value.  These are fairly simple items.  Unfortunately, a number of developers don’t quite understand this.  Many developers just want to write code, “But Wally, I just want to write code.  It is why I got into this job.”  Or, you may be a part of some IT group where you are seen as a cost center.  Whatever your position within the organization, getting out and talking to users has resulted in my finding the following items:
  • Users want applications that look just like all of the other applications on their platform.  Giving a user an application that looks like a Windows application while running on the Mac can result in some interesting feedback.
  • Users want applications that act just like all of their other applications on their platform.
Basically, this means that an application must call platform specific APIs and must do so fairly close to the application logic.  By doing this, the application will look, smell, and taste just like every other application on a platform.  An iOS application will look like iOS.  An Android application will look like Android.
History’s Lessons
I’ve done a little bit with cross platform tools in the past.  Early on in my career when I worked at The Cola-Cola Company, there was some involvement with:
  • PowerBuilder for the Mac.
  • Visual C++ for the Mac.  While this never shipped, it existed to the point of us getting an NDA. It may have only existed to create FUD.
After talking to users and working through some options, this is where I learned how important it is for apps to look like the other apps that users use.
A few years later, Java came on the scene.  Unfortunately, Java ran into several issues:
  • Java apps didn’t look like other apps on a given platform.  Swing came out later on and it provides a much more platform specific look/feel to it.
  • Early on, Java wasn't very fast, let's just be honest about it.
  • Java had small incompatibility issues between platforms.  Its promise of “Write Once Run Anywhere” had become “Write Once Debug Everywhere.”
  • There was no guarantee that the Java framework was on a device.  Expecting a user to install the framework was no realistic.
As we know from history, Java, while being widely used in the development area, never saw a great uptake in the consumer space.
Not long after Java, Microsoft .NET came on the scene.  Unfortunately Microsoft .NET never took over outside of the Windows space.  Its cross platform capabilities never really came about.
Now, I am sure that there is someone jumping up and down widely waving their arms and screaming “HTML5, HTML5 will save us.”  Ultimately, HTML was designed for the display of documents and content to users.  Back in the mid 1990s, the reason why HTML took off was due to:
  • Deploying most custom apps within a business was a nightmare.  Deploying apps to a web browser was much easier.  No dll hell, no installation programs to run, life was much better.  Imaging trying to do this outside of a company without a support staff?
  • Early web sites were much more about marketing.  Very few public web sites back then were about applications.  It took a few years for web sites to take on more of an application feel to them and now many have an app feel to them.
While there have been many attempts to give an HTML file device like capabilities, these capabilities always seem to be lacking in something.  Mobile web apps with HTML5 are no different.  There is always something that they can't do.  For example, I’m working with some folks that are trying their hardest to get out of phonegap due to limitations of the platform.  Now, I’m not going into the specifics on that, merely that there are issues and these aren’t the only folks with them.
Just so that we're clear on things, HTML web apps work out really well in a lot of situations.  I've written a lot of them.  I'm a Microsoft ASP.NET MVP (well at least for a little while longer).  I continue to work on several.  They just aren't the go to platform for mobile.

Developer Productivity
One of the big arguments I hear regarding using a single set of source files to build an application, is that this is more efficient for developers.  I agree, this is absolutely true.  Unfortunately, user productivity is 10-100x more valuable than developer productivity.  Increasing user productivity by a small percent multiplied by the number of users results in a greater increase in productivity.
But, But, But HTML5……While I will argue the point about user productivity increases dwarfing developer productivity, I’m not going to be unrealistic regarding what is happening in the marketplace.  There are some places where having a single set of course files is valuable.  These typically are:
  • The client only has a few shillings to pay for a solution.  The cost of an HTML5 mobile web solution is lower, let’s be honest about it.  You can get your neighbor’s kid to do the work.  This has a tendency to drive down the price. I’m just sayin’.
  • If your IT department is considered to be a cost center.  Build something, deploy it to a bunch of platforms, later, rinse, repeat.
Unfortunately, the problem with HTML5 is that you just can’t integrate with the platform as well as the client wants to.  Because HTML5 fits in a low cost area doesn’t mean that it fits everywhere.  A secondary issue is that as a client wants an application to grow and provide more functionality, a continually higher cost must be paid for this functionality.  Eventually, you will reach a point where the cost of a mobile web html5 solution meets and passes the cost of native mobile apps and still not providing the native experience.  What happens with that mobile web html5 solution?  It becomes a sunk cost.  You will end up throwing it away and pretty much starting over on the client side..
PhoneGap Will Save Us
Sorry folks, but PhoneGap isn’t the be all and end all.  PhoneGap is a container that embeds HTML, JS, and CSS content.  It allows access to device APIs in a cross platform way.  Unfortunately, you get access to content via a web view, so you are limited to what can be provided in the web view.  
I almost went down the PhoneGap route back in 2009, until I read the first announcement of MonoTouch (now Xamarin.iOS).
But I do Java, ObjectiveC, or something else
Ok, great.  There are tools for Java that allow you to write for iOS.  Unfortunately, that won’t help you with WP.  The same is true with ObjectiveC.
Why XamarinWhen Xamarin.iOS was first announced, I knew that was where I needed to be.  It provides:
  • Access to the native APIs directly from an application via the bindings contained in the various namespaces in Xamarin’s products.  If your application isn’t calling native APIs, your application will most likely have small things that are out of place in some way.  This immediately solved the problem that I had 20 years ago.
  • Access to the .NET framework that I already know. I don’t have to go learn ObjectiveC, Java, Xcode, Eclipse, or Android Studio.  I can use Visual Studio to develop apps for multiple platforms. I don’t have to go learn a new IDE.
  • Sharing non-device specific code between iOS, Android, WP, and other .NET platforms.
  • Learning the UI specifics and platform-isms allows you to build an application that integrates with the platform better than a shared application.
I have heard the chimes at midnight.  I have gone through the cross platform battles in the past.  The bottom line is that you have to create platform specific versions of your app.  I think that Xamarin is the right place for me.  I’ve learned my lesson. I’m calling native APIs with my language of choice, C#.
If you are interested in a discussion regarding Xamarin vs. Vendor Directed solutions, I suggest this discussion in the Xamarin forms:http://forums.xamarin.com/discussion/comment/36834  

Wednesday, December 4, 2013

Cross Platform with Visual Studio 2013 & Xamarin Meetup - Atlanta - December 11

I'll be at a Meetup in Atlanta on December 11, 2013.  I'll be talking about:
  • What is cross platform?  What is meant by it?
  • What are the options for cross platform?
  • What is Xamarin/what do they provide?
  • What can I do with Visual Studio 2013?
  • What are PCLs/linked files?  How to share business logic?
  • What about shared APIs?  What is Xamarin.Mobile?
  • What about Data?
For more information, check out the meetup site.

Wednesday, November 6, 2013

Webinar on Cross Platform Development with MonoTouch for the iPhone and Mono for Android on Wednesday

The iPhone and Android are dominant in the marketplace. The two platforms currently have 85% of the smartphone marketplace and are continuing to grow that marketshare. Developers are being tasked with targeting these two platforms. In this session, we’ll take a high level look at how we can use c# and .NET knowledge to share code between iOS and and Android. We’ll look at linked files, using the Xamarin Mobile API, the challenges of running across platforms and frameworks, as well as other features of Visual Studio, Monotouch, MonoDevelop, and Mono for Android that allows us to write as much code that can run on both platforms.

Friday, October 11, 2013

Async & Await in C# with Xamarin

One of the great things about the .NET Framework is that Microsoft has worked long and hard to improve many features. Since the initial release of .NET 1.0, there has been support for threading via .NET threads as well as an application-level threadpool. This provided a great starting point when compared to Visual Basic 6 and classic ASP programming. The release of.NET 4 brought significant improvements in the area of threading, asynchronous operations and parallel operations. While the improvements made working with asynchronous operations easier, new problems were introduced, since many of these operations work based on callbacks. For example:
  • How should a developer handle error checking?
  • The program flow tends to be non-linear. Fixing bugs can be problematic.
  • It is hard for a developer to get an understanding of what is happening within an application.
This article will look at how Xamarin has implemented the .NET 4.5/C# 5 support into their Xamarin.iOS and Xamarin.Android productions. There are three general areas that I'll focus on:
  • A general look at the asynchronous support in Xamarin's mobile products. This includes async, await, and the implications that this has for cross-platform code.
  • The new HttpClient class that is provided in .NET 4.5/Mono 3.2.
  • Xamarin's extensions for asynchronous operations for Android and iOS.
FYI: Be aware that sometimes the OpenWeatherMap API breaks, for no reason.  I found this out after I shipped the article in.

Thursday, October 10, 2013

What's new in Xamarin and iOS7 - webinar

I recently did an online webinar regarding the new iOS7 and Xamarin.  In it, I covered the basics of what is new in iOS7 along with what is new in Xamarin's developer platform.  Please take some time and view this webinar.  The items that were covered include:
  • What's new in iOS7.
  • The XCode Design Surface.
  • An example showing new iOS7 View Animations.
  • What's new with Xamarin and async, await, and HttpClient.
  • A demo of Razor Templating.
  • The Xamarin.iOS Plugin for Visual Studio.
  ** The video only works in Windows.  I don't control the content, so I have to go with what I am given. :-( **

Monday, September 16, 2013

Building a UI in Xamarin.iOS

No matter your feelings toward Apple, there's no denying the marketplace likes the iPhone and iPad family of products. You can't ignore them, and because you're reading this column, I thought it would be interesting to look at the options you have for creating a UI with Xamarin.iOS. There are two options I'll look at in-depth:
  • Using the XCode design surface integration with Xamarin Studio.
  • Programmatically creating controls.
The article is at: http://visualstudiomagazine.com/articles/2013/09/01/creating-a-ui-in-xamarin-ios.aspx