latest posts

This morning I will be presenting at the Maryland Code Camp with the topic of Developing Once and Deploying to Many, specifically talking to practices and patterns I've found to help create rich mobile applications efficiently over the last 3 years I've been actively developing for the mobile space. WCF, WPF, PCL, MonoDroid, Azure Mobile Services and Windows Phone 8 are to be discussed.

For the Powerpoint 2013 presentation, all of the code going to be mentioned during the session, the SQL, PSD files and external libraries used, click here to download the zip file.

In addition during the session I will be making reference to an app I wrote earlier this year, jcLOG-IT, specifically the Mobile Azure Service and Windows Live Integration elements.

The code block mentioned for Authentication: [csharp] public async Task AttemptLogin(MobileServiceAuthenticationProvider authType) { try { if (authType == MobileServiceAuthenticationProvider.MicrosoftAccount) { if (!String.IsNullOrEmpty(Settings.GetSetting(Settings.SETTINGS_OPTIONS.LiveConnectToken))) { App.CurrentUser = await App.MobileService.LoginAsync(Settings.GetSetting(Settings.SETTINGS_OPTIONS.LiveConnectToken)); } else { var liveIdClient = new LiveAuthClient(Common.Constants.APP_AUTHKEY_LIVECONNECT); while (_session == null) { var result = await liveIdClient.LoginAsync(new[] {"wl.signin"}); if (result.Status != LiveConnectSessionStatus.Connected) { continue; } _session = result.Session; App.CurrentUser = await App.MobileService.LoginAsync(result.Session.AuthenticationToken); Settings.AddSetting(Settings.SETTINGS_OPTIONS.LiveConnectToken, result.Session.AuthenticationToken); } } } Settings.AddSetting(Settings.SETTINGS_OPTIONS.AuthType, authType.ToString()); Settings.AddSetting(Settings.SETTINGS_OPTIONS.IsFirstRun, false.ToString()); return true; } catch (Exception ex) { Settings.AddSetting(Settings.SETTINGS_OPTIONS.LiveConnectToken, String.Empty); return false; } } [/csharp] The Settings class: [csharp] public class Settings { public enum SETTINGS_OPTIONS { IsFirstRun, LiveConnectToken, AuthType, LocalPassword, EnableLocation } public static void CheckSettings() { var settings = IsolatedStorageSettings.ApplicationSettings; if (!settings.Contains(SETTINGS_OPTIONS.IsFirstRun.ToString())) { WriteDefaults(); } } public static void AddSetting(SETTINGS_OPTIONS optionName, object value) { AddSetting(optionName.ToString(), value); } public static void AddSetting(string name, object value) { var settings = IsolatedStorageSettings.ApplicationSettings; if (!settings.Contains(name)) { settings.Add(name, value); } else { settings[name] = value; } settings.Save(); } public static T GetSetting(SETTINGS_OPTIONS optionName) { return GetSetting(optionName.ToString()); } public static T GetSetting(string name) { if (IsolatedStorageSettings.ApplicationSettings.Contains(name)) { if (typeof(T) == typeof(MobileServiceAuthenticationProvider)) { return (T) Enum.Parse(typeof (MobileServiceAuthenticationProvider), IsolatedStorageSettings.ApplicationSettings[name].ToString()); } return (T) Convert.ChangeType(IsolatedStorageSettings.ApplicationSettings[name], typeof (T)); } return default(T); } public static void WriteDefaults() { AddSetting(SETTINGS_OPTIONS.IsFirstRun, false); AddSetting(SETTINGS_OPTIONS.EnableLocation, false); AddSetting(SETTINGS_OPTIONS.LocalPassword, String.Empty); AddSetting(SETTINGS_OPTIONS.LiveConnectToken, String.Empty); AddSetting(SETTINGS_OPTIONS.AuthType, MobileServiceAuthenticationProvider.MicrosoftAccount); } } [/csharp]
Digging through some posts that had been in draft for months, I forgot I wrote up some notes on the new Immutable Collections, still in Beta. Since diving into Task Parallel Library (TPL) in September 2011, I've become very attached to writing all of my code especially in my WCF Services, WPF and WinForms apps to utilize parallel programming as much as possible. So when I found out there were brand new immutable collections in the System.Collections.Immutable namespace I was very excited. To get started, goto NuGet and download the package. From there using the collections is extremely easy: [csharp] var testList = System.Collections.Immutable<String>.Empty; testList = testList.Add("Cydonia"); testList = testList.Add("Mercury"); [/csharp] The key thing to remember especially those accustomed to using the System.Collections.List collection type is to take the return value of the action (in this case Add) and reassign it to the collection. One of the first questions you might ask, why should I use these collections instead of ? The better question I think is to ask yourself, what problem are you trying to solve and which collection makes sense? I'm definitely going to be keeping an eye on the project, especially when it comes out of Beta.
Luckily, there was a HP Pavilion dmz1 E-350 (2x1.6ghz) at work that a co-worker was able to run jcBench on so if you were curious about Ontario vs. Zacate vs. Champlain vs. Trinity core pure CPU performance now is your chance to see. Integer Performance: [caption id="attachment_1285" align="aligncenter" width="300"] AMD Ontario vs Zacate vs Trinity vs Champlain CPU Integer Performance[/caption] Floating Point Performance: [caption id="attachment_1286" align="aligncenter" width="300"] AMD Ontario vs Zacate vs Trinity vs Champlain CPU Floating Point Performance[/caption] As expected the E-350 was in between the 2010 Champlain CPU, but what was more interesting was the lack of a dedicated FPU for each Integer Core in the Trinity CPU in the Floating Point benchmark. While still faster in the A10 versus the P920, it wasn't as dramatic as the Integer performance difference. It should be interesting how AMD tries to combat the floating point deficit it most likely faces against Intel's cpus. If I had to guess, I'd say more emphasis on using the integrated Radeon 7xxx series is key to the success of Trinity. Regardless of the platform using OpenCL or C++ AMP is a better route to go nowadays than strictly programming for a CPU as a traditional multi-threaded development would go. Definitely will revisit this in the coming weeks when the new version of jcBench that supports TPL, C++ AMP and OpenCL is released.
I was reading about AMP the other night, basically a light weight C++ wrapper that is used to offload tasks to your GPU. I was going to brush off my C++ skills tonight, but luckily I don't have to after reading this article. WinRT makes using C++ libraries a breeze, finally you don't have to use p/invoke. I'll definitely be playing around with this as soon as my Visual Studio 11 installation issues get resolved. A word to the wise, if you're installing Windows 8, install it with the Developer Tools. I made the mistake of installing the non-developer tools Windows 8 Developer Preview, which doesn't install the necessary SDK for C++ compiling. If you're only doing C#, I had no trouble programming/compiling WPF and WCF apps.