The Case for Xamarin

Posted: June 7, 2013 in Cross-Platform, Xamarin

As an enterprise mobile app developer, you will eventually be faced with the decision of choosing the right tool set to develop cross-platform mobile apps. Should I go native?  Should I go hybrid with Cordova (PhoneGap)? Should I use an HTML5 (Sencha Touch,KendoUI, jQuery Mobile) framework? Each has its own merits and demerits.

There is no question pure native apps offer the best of all metrics. You get the best performing (of course limited by your coding skills) app sporting the best looking native UI and, the best user experience. You can leverage all of the device capabilities. You can use all of the native controls ensuring the app subscribes to the platform paradigms. The app feels and behaves like a native.

HTML5 frameworks have come a long way and offer features often rivaling native controls in their look and feel. You can design great looking apps. HTML5 frameworks are often positioned as the solution for developing cross-platform write-once-run-everywhere apps. But take a step back and mull over this.

Unless you want your app looking the same on iOS, Android, Windows Phone and Blackberry, it’s not a write-once-run-everywhere solution. If you want your apps to subscribe to platform specific UI paradigms, you have to sprinkle branching logic in your UI code. Yes, you may have separated your UI into distinct layers, but to offer platform specific UI, you have to write platform specific HTML5 code.

The case is not any different for hybrid apps either. Once again, unless you are ready to live with your UI satisfying the lowest common denominator, you have to write platform specific UI code.

I am assuming you have abstracted the business logic to back-end services callable from the HTML5 or the hybrid app.

So, regardless of whether you choose to go native or HTML5 or Hybrid you have to write platform specific UI code to ensure your app looks and feels native. You may get away by sprinkling your Javascript with branching code but it will soon turn into a debug hell.

This is where Xamarin can help and shines. Xamarin does not promise that you won’t be repeating your UI work. However, Xamarin affords you the ability to write true native apps leveraging native UI paradigms and controls and yet, share business logic code. To use the cliché, it’s a Win-Win! Xamarin allows you to use XCode (storyboards too) to create your awesome native iOS UI, XAML for your Windows Phone UI and, XML for your Android UI. So just like you would, if you decide to use an HTML5 framework or go the hybrid route, with Xamarin you are coding platform specific UI. However there is no branching. And, the resulting app is a pure native app offering you all the benefits like if you had developed the app in Objective-C, C# or Java. What’s not to like about that, especially if you are coming from a .Net world? If you are going to spend your energy creating platform specific UI, why not channel that to leverage the best native UI each platform has to offer? Many enterprise software systems are created in .Net. You may argue that not all enterprise software is. Most consumer facing apps first target iOS and then Android. C# is an easier transition than Objective-C for someone coming from the Java world.

Think about it.

Why I like PythonMonk

Posted: April 13, 2013 in Uncategorized

For a while I have been thinking about learning a dynamic programming language. These are the best days to be a young fella with time on hand. Computing power has become cheap and you no longer have to target one or two OSes from giant monopolies. Heck even Macs are cheaper. And right out the box these machines (Macs) come with everything installed for creating awesome software solutions. If not, whatever you need is just a repository away on GitHub.

My passion is Healthcare IT. I am always on the lookout for good EMRs and Hospital Management Systems that may be implemented for use in 3rd World countries. Once you bring in the restriction of cost, you are pretty much cornered into looking for systems built using free open source solutions. And, most of these are developed in software ecosystems I have not extensively worked in. When I discovered OpenMRS, I was thrilled by the features it offered and, the fact that it was actively being developed and used in African countries was even more reason to gravitate toward it. But. There’s always a but. OpenMRS is built in Java. Although I am not planning on monkeying with the code daily, it helps to be able to roll up your sleeves and just start debugging. The entire ecosystem did not feel like home. The Java ecosystem has matured so much its just wasn’t inviting. Don’t get me wrong. All of this is based on pure gut. I have nothing against Java. But I don’t like it that Oracle now owns Java. Then I discovered GnuHealth. An open source Hospital Management System developed in Python.

Ruby is very popular. It’s a dynamic language. Has matured enough for CodingHorror to pick it up for his next big thing called Discourse. I have the Ruby pickaxe book. My friend Lucid coder raves about it too. But I still wasn’t sure because there are not EMRs or HIS built on Ruby. 

That brings me back to Python. I have been paying a little attention to Python but never seriously. It was time. Having settled on that, next up was to figure out where to begin. Google search threw up several resources. Mainly pointing to Learn Python the Hard Way. This might be the best way to master Python but it certainly will take a while to complete. Then I signed up for Codeacademy. This is good but a little elementary and slow paced for my needs. 

 I realized that my needs are different from the needs of someone wanting to learn a new programming language. Most tutorials target novices. People who have no programming background. But I want to learn how to develop software solutions with a new programming language. Although getting a good grip on fundamentals is paramount, I don’t need to start at learning what variables are, what for loops are or what ifs are. If you do not have a programming background Codeacademy works great. 

As if on cue, the awesome folks at CodeMonk released PythonMonk. I have been “following” the maturity of RubyMonk, although I had not spent time experiencing it. It was like everything was aligning in the heavens. My discovery of GnuHealth. Deciding Python is what I want to learn and the release of PythonMonk.

I signed up and completed the lessons and problems in 2 days.

If I have to sum up the experience of PythonMonk in one phrase, “Mind Blowing” is what I would use.

And here is why.

The lessons are simple with just enough concepts targeting both novices and experienced programmers. People with no background can comprehend the concepts but there is enough intrigue for experienced programmers to relate to learned concepts. The problems presented at the end of each concept build upon what has been learned but don’t let you blindly bang out code. You have to stop and think, no matter how simple the problem is. This, in my opinion, is the biggest differentiation of PythonMonk compared with other tutorials. Anand has done an extremely awesome (I know I cant stop gushing) job putting together these lessons. Monk suits perfectly. Most tutorials present problems which can be completed using only the concepts presented earlier. You can waltz through them. Not here. Not on PythonMonk. 

The last problem of sorting a list by file name extensions is interesting. This problem is what led to my epiphany. The solution is pretty simple. However, it cannot be completed purely by picking up the concepts presented. You have to venture beyond, on your own, learn a bit more and then solve it. The solution needs an extra concept that is not directly presented in  any of the lessons. But if you are the curious type, then you would have learned it on your own building upon the lessons presented and arrived at the simple solution. This is the power of PythonMonk.

I haven’t become a Python expert after completing the lessons on PythonMonk but, these lessons have filled me with enough intrigue and passion to continue my education and have armed me with enough concepts to dig further.

Hats off to you guys at CodeMonk. Thanks for PythonMonk and keep up the awesomeness. 

Being new to Android development I struggled with this one for some time and hopefully this post will save some poor soul the agony I went through.

After I added a TabHost widget to my Layout I assumed I could attach an event handler to either the TabSpec component or the TabHost itself and listen to these events in the activity. But this does not work. Googling and trolling stackoverflow threw up old references which no longer were valid for 4.0.1 version of the SDK I am targeting.

However the technique is very simple. 

The TabHost has a method named “SetOnTabChangedListener” which takes in an instance of class implementing the IOnTabChangeListener interface. 

So all you got to do is implement IOnTabChangeListener in your Activity and set the listener on the TabHost like so

TabHost.SetOnTabChangedListener(this)

Your activity class needs to implement only the OnTabChanged method and you are golden. This method is called when any tab is clicked and you may do whatever pleases you in the method. The tabId is passed in as a parameter. This is the same string you used when setting yo individual tabs.

spec = TabHost.NewTabSpec(“home”);

There you have it. Enjoy.

My current reading list

Posted: September 21, 2011 in musings, ramblings

After a really long time, I just took a break from constant coding and read The Kingkiller Chronicles Day 1 (The Name of the Wind) and Day 2 (The Wise Man’s Fear) back to back. Enjoyed it although felt both were rushed toward the end as if the author wanted to finish the book under 900 pages. Local library is a great place to borrow books and now with Kindle lending this should be even better.

Here is the list of books in the queue

1. Sencha Touch in Action by Jesus Garcia and Anthony DeMoss

2. Node.js in Action by Mike Cantelon and TJ Holowaychuk

3. HTML5: Up and Running by Mark Pilgrim

4. Programming Razor by Jess Chadwick

5. jQuery Mobile: Up and Running by Maximiliano Firtman

6. Pragmatic guide to Sass by Hampton Catlin and Michael Lintorn Catlin

7. CoffeeScript Accelerated Javascript Development by Tervor Burnham

8. Meaningful Use and Beyond A Guide to IT Staff in Health Care by Fred Trotter and David Uhlman

9. The Way of Shadows (The Night Angel Trilogy) by Brent Weeks

10. Wired by Douglas E. Richards

11. The Frozen Sky by Jeff Carlson

WOW! not sure how I am going to find time to read them all.

2010 in review

Posted: January 2, 2011 in Review

The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads This blog is doing awesome!.

Crunchy numbers

Featured image

A Boeing 747-400 passenger jet can hold 416 passengers. This blog was viewed about 2,400 times in 2010. That’s about 6 full 747s.

In 2010, there were 6 new posts, growing the total archive of this blog to 57 posts. There were 9 pictures uploaded, taking up a total of 1mb. That’s about a picture per month.

The busiest day of the year was October 18th with 106 views. The most popular post that day was 5:01 Developer.

Where did they come from?

The top referring sites in 2010 were sterling.codeplex.com, davybrion.com, twitter.com, silverlightshow.net, and reddit.com.

Some visitors came searching, mostly for stylecop vb.net, stylecop for vb.net, stylecop vb, vs2008 trial upgrade, and upgrade vs 2008 trial.

Attractions in 2010

These are the posts and pages that got the most views in 2010.

1

5:01 Developer August 2007
13 comments

2

Using the Sterling database in your Windows Phone 7 App November 2010
2 comments and 1 Like on WordPress.com,

3

Upgrading trial version of VS2008 to licensed version February 2008
2 comments

4

Opening an iPhone 3G – Be Extra Careful January 2010
1 comment

5

It takes guts to do Agile scrum March 2010
3 comments

Do you track your blood glucose, blood pressure, heat rate and, weight readings as part of your health maintenance goals? Then HealthCaddy is your buddy. This Windows Phone 7 App helps you track these important health readings.

The main reading entry screen displays a quick snapshot of four most recent entries. Double-tap the graph to display a full-screen version of the graph which also allows you to view historical readings.

HealthCaddy uses the CTP version of Telerik Windows Phone 7 date and time picker controls. Data is stored to the phone’s isolated storage via the excellent Sterling database engine. And, like discountCalc, HealthCaddy also uses MVVMLight framework to achieve UI and business logic separation.

Here are a few screen shots of the app.

HealthCaddy_ScreenShot1HealthCaddy_ScreenShot2

HealthCaddy_ScreenShot3HealthCaddy_ScreenShot4

HealthCaddy_ScreenShot5HealthCaddy_ScreenShot6

I had to cut out certain features of the app to hit the December 31st 2010 deadline. I intend to implement these ASAP. I am also awaiting the release of version 1 of Telerik controls and the Sterling database engine. These updates will be rolled into the next point release.

I have also setup a UserVoice forum to solicit feature suggestions for future implementations. Post your feature requests here and cast your votes.

discountCalc, my first Windows Phone 7 App has been published and is available in the Windows Phone 7 Marketplace. It is a very simple discount calculator but unlike typical discount calculators, discountCalc allows you to specify two discount amounts and computes the total discount. This is especially useful when shopping at the big box stores where they like to throw in a additional discount for that day. Say, you want to figure out the price of an item discounted at 50% with an additional 15% discount. Most people erroneously assume that they are getting a 65% (50 + 15) discount. Computing 15% of 50%, although not impossible, is not trivial. discountCalc takes any guess work away and makes figuring out the final price very easy. Just plug in the numbers and you get the answer. You can even play with the percentage numbers and discountCalc does on-the-fly computation. Here are  screen shots of the app.

 DiscountCalcScreenShot DiscountCalcScreenShot2

From idea to marketplace, developing for the Windows Phone 7 has been a breeze. Granted it is a very simple app, but I wanted to get the experience of inception to marketplace. Overall, I am extremely happy with the experience. I bought a Mac Mini to develop iPhone apps but never got enough hang of Objective-C to create an app. It’s not that Objective-C is hard but I found it difficult to find time to become knowledgeable enough to create an app. The fact that I use Silverlight in my day job helped me build this app quickly. Creating the art work and getting it just right too some time.

I would like to thank the following people for extending their help during the development of this app. Without these bright folks’ support I could not have published this app.

1. Dele – My cohort at work. Extremely fortunate to be working with such a talented individual. Having successfully published his app (Easy Diary), Dele, helped me get unstuck several times and offered invaluable review comments

2. Joel, Microsoft MVP (Mobile) – Without Joel lending me one of his several Windows Phone 7 devices I could not have tested my app on an actual device. Probably would have had to wing it and risk rejection. Testing on a device is invaluable and for this I am indebted to Joel.

3. Laurent Bugnion, Microsoft MVP (Silverlight) creator if MVVMLight, a Model-View-View-Model framework for WPF, Silverlight and Windows Phone 7 applications. Enjoyed working with MVVMLight. A big thank you to Laurent for trying to help me with what I assumed was a MVVMLight framework but. It actually turned out to be one of the Telerik DLLs.

If you have a Windows Phone 7, please check discountCalc out. All feedback welcome.

del.icio.us Tags: ,