Tuesday, May 14, 2013

Why to switch from Android to Windows Phone

Switch to Windows Phone, Why?

I have been debating this myself for many weeks, as I have patiently waiting for my carrier, Verizon Wireless to offer the new phone models.  My main debate has been between the Samsung Galaxy S4 and the Nokia Lumia 928.
 
I am not going to go into the specifics about the hardware or vendor specific software, there are plenty of source for this type of information.  I am going to cover fundamental reasons why now is the time to switch to windows phone. 
 

Less carrier and manufacturer modifications

Windows Phone OS's core functionality is by design protected from manufacturer modifications.   This means while device manufactures and even wireless carriers like to add bloat ware and make other core system modifications to the Android's Open Source OS which can cause instability, battery drain, privacy concerns and additional security wholes.
 

Frequent updates, improved security

 
Unlike Android devices updates are not controlled by the cellular carrier, which from my experience are either up to a year past the current Android version, even then the devices only get one maybe two system updates to the operating system.  This is a major concern from my perspective because it means that any security flaws that are fixed in the newer releases are never going to make it my device unless I root it and void any warranty/support for the devices.
 
With Windows Phone the updates come from Microsoft, not the carrier or device manufacturer. No rooting require, no voiding the warranty or support agreements with the manufacturer or carrier.  These updates have been through the proper testing and Microsoft already has a great focus on security, case in point from the windows OS side is a little thing we like to refer to as "Patch Tuesday's".
 
Now Samsung recently was awarded a government contract for their knox software which is a vendor specific piece of software and again subject to carrier changes. But still good news for newer Samsung devices.
 

App market growing

If you expect to find every title that you had in Android, that is not going to happen.  This is a downside but as windows phone is gaining market share and the non-Microsoft ecosystem developers are discovering the easy of app development and fact that all web developer and windows 8 developer skill set cross all platforms there is a strong army of developers that are bringing new apps to the market every day.  I personally, have a couple apps that I am planning to write. 
 
Microsoft is aware of this as being one of the biggest hurdles to making the switch and they are addressing it as discuss in this Computer World article http://www.computerworld.com/s/article/9237836/Windows_8_app_store_growth_slows. 
 

#TimeToSwitch Android Application

Microsoft in an effort to make the transition easier has published an app to the Android market its called TimeToSwitch.  This app is designed gather what apps you have installed on your phone, save it and when you switch to windows phone it will help you find the same or similar apps in the windows store.  While the key phase in the last statement is same or similar I think there is room for improvement in this application to display the list of which will be same and which are similar a head of time, but hey this is a great start and much easier than the transition from one android device to another.
 

Easy contact migration

Since this uses the SkyDrive and your windows live account, guess what you want your contacts no biggie, log into http://www.outlook.com and important any contacts that you synced with Google or the other social media sites. 
 

Companion Applications for both Windows Phone and Windows 8

 One of the best features is that many of the applications your purchase (paid or free) for windows phone also have a windows 8 compatible version.  Who doesn't like a buy one get one? 
 

SkyDrive and Office Applications

Everyone windows phone comes with free space on SkyDrive, the Nokia Lumia series is stated as coming with 7gigs free.  This makes it really easy to access files from both your PC and on the via your phone or surface tablet.  Having used similar services like Drop Box for similar functionality in Android this was even simpler to setup and even easier to use.
 

Developer Perspective:


Modern UI (Metro) consistencies

The consistency of live tiles between windows phone, windows 8 is a nice change.  Also makes development and design easier which is great for me as a develop who lacks the skills to create amazing looking UI designs.


Its all just HTML5 (faster development) and JavaScript

That's right!  Web Developers and Windows Developers unite, we can draw on the same skill sets for developing for Web apps, Windows Phone, and Windows 8.  What I really like is that I can leverage any and all of the Web API's that I have built for my MVC sites for consumption in my windows phone apps and Windows 8, allowing me to greater code reusability.
 

You are going to pay me to publish apps, sign me up?

If you read the computer world article you will notice that they talk about pay developers to publish application to spur app market growth, well guess what that was just the extra motivation to get me started several app ideas I have been wanting to write. 
 

*** All Content is provided As Is ***

jQuery.noConflict() you smell like a stinky cheese!

So a little background

I was working on a project implementing a design into a project which included the html, graphics and a few javascript libraries and files. Upon initial investigation everything seem on par with what you would expect from a UI using jQuery and jQuery UI. I ran the provided files in the browser and everything seemed okay, no console errors in the browser debugger. It was using a few jQuery plugins that I have never used before but everything seemed to be displaying correctly except for the adGallery plugin, but I wrote that off to a minor error somewhere in the css or markup, knowing that if all else fails, I could easily implement a different plugin like PikaChoose to maintain the functionality.

Now to fix the adGallery

While integrating the design into the functional site I notice on of the javascript files it used jQuery.noConflict(). I didn't recognize this tag as I had never used it, but the jQuery library is pretty expansive and given no browser debugger error I wrote it off to my own lack of knowledge and moved on to trying to fix the adGallery. In Visual Studio, I reviewed the markup and css and both seemed inline with what the documentation was showing but when I ran it Visual Studio I would get an error stating adGallery is not a supported method or property. I did a little searching and nothing turned up about compatibility issues, so I chalked it up to conflict causing the jQuery library to not compile properly at run time. So I switched the markup, css and library out with PikaChoose and attempted to run in debug again.

Here is the smelly part

Unfortunately the error remained only stating that PikaChoose() is not a supported method or property. Having used this before I knew that it worked. This is when I noticed the jQuery.noConflict() a few lines above it, so on a whim I moved my instantiation code above this line and everything ran okay in debug. So I removed this line of code and a new error came light stating that Method of Property 'msie' was not found or null. Turns out that this error was related an incompatibility between jQuery 1.9.1 and jQuery UI 1.8.11.

So what is jQuery.noConflict() used for?

jQuery.noConflict() relinquished the control of the $ object. This would mean that any errors would not show in the debugger because the $ object would be empty or null. For more information on the proper usuage of jQuery.noConflict() check out the API Documentation at http://api.jquery.com/jQuery.noConflict/

In summary if you ever see jQuery.noConflict() make it is truly being used for its intended purpose.

*** All Content is provided As Is ***

Monday, May 6, 2013

CoAuthoring a new NuGet Package csharp.Extensions

A fellow developer and I have decided to coauthor a NuGet package to help us from having to constantly added the same extension methods to our projects.  This project is called csharp.Extensions.  Available at https://nuget.org/packages/csharp.Extensions/

These extension methods allow for quick expansion of the base csharp types including common functions such as converting a comma separated string into a list, or converting a nullable datetime to a non nullable datetime.  We have not compiled the code based because we encourage you to use them and extend them as necessary.

If there is an extension method missing and you would like to added please let us know.  To use in NuGet Package Manager Console type install-package csharp.Extensions.

I hope this helps save you some time and if you have any questions don't hesitate to ask.

*** All Content is provided As Is ***

Wednesday, July 20, 2011

Glimpse from NuGet

Some of you by already know the wonders of Glimpse for ASP.net and the newer released Glimpse for MVC.  If you are not familar with this product I recommend that you check out the products website for more details.  (http://getglimpse.com/)

I have recently been exposed to the wonders of Glimpse for MVC which the route detections, strongly typed entity inspections client side, and other various tools is hugely helpful in diagnosing what is happening within the views which you typcially do not have a lot of inspection options related to entities.

But I will give you a tip about this product and beware of a few issues.

I am a big fan of Lazy Loading for Entity Framework 4 really enjoy the simplistic nature of the syntax that allows for faster development with greater emphases on business logic versus lines of code.  So the biggest issue I have ran into is when children entities of children entities are lazy loaded and you have glimpse turned on for the site, a referenced entity has been disposed run time error will be generated.  Simply turn off Glimpse and issue will disappear. 

Given that Glimpse is currently in beta, I look forward to the polished product that will take these issues into account.  But for being in Beta, it is truely a great utility even with the few bugs that are in the product.

*** All Content is provided As Is ***

Using Extension Methods in MVC

As many .Net developers have learned extension methods provide a mechanism to quickly add on capabilities to existing data types and methods.  If you are unfamilar with Extension Methods, Microsoft provides a great tutorial and documentation via MSDN (http://msdn.microsoft.com/en-us/library/bb383977.aspx). 

This particular post is related to utilizing these methods within MVC and the necessary work around for them to work with in your code.

Setup:

  1. Create your extension method as normal, and put your Class in a folder you created to house your extensions (typically done in the App_Code folder in ASP.Net web apps - this is not a folder that is an available system folder for MVC)
  2. Perform a build via the build menu or CTRL+SHIFT+ B
  3. Attempt to add the Using statement to the top of controller, data model, or class.
Why is my namespace not showing up?

Well, this is because in MVC by default the class is added with a build action of "Content".  This means that when you build the application it did not compile your extension method class.

So how do you fix this?

This actually extremely easy via the following:
  1. Right click on the extensions class file you created
  2. Select Properties
  3. The first option in properties window is Build Action
  4. Select Compile from the drop down
  5. Build the application
Your extension methods namespace should now be available to reference in any of the other classes, controllers, data models via the Using statement. From then on within that particular class you can use your extension method as normal.

*** All Content is provided As Is ***

The Conversion of a datetime2 Data Type to a datetime Data Type Resulted In an Out of Range Value

This particular error was produced when using Entity Framework where the edmx is generated from a SQL Server 2008 database.  This particular issue was rather nerve racking giving that I was providing the property of the Entity that a DateTime.Now value.  Which works perfectly in other areas of the application, as expected.

Background:

There was two tables in question, TableOne has a non-nullable foreign key constraint to the primary key field of TableTwo.  This is highly common and not something that is an issue, obviously the record in TableTwo had already been created and the ID was being supplied to the TableOnes entity.  So when attempting to perform db.TableOnes.AddObject(tableone) and calling the db.SaveChanges() produced the following error "The Conversion of a datetime2 data type to a datetime datetype resulted in an out of range value." 

Diagnosis:

I verified through stepping through the code and inspecting the entity that the value being supplied for the only datetime property of the tableone entity was a valid datetime.  I attempted dropping the TableOne entity from the edmx and re-adding it.  Only to still produce the same error.  Given that the inner exception message was being provided from SQL Server, I decided to inspect the sql statement that entity framework was passing to the database since, the emdx has no datetime2 mappings for any of the tables to entities. 

Side Note:
To inspect the sql statements use SQL Profiler - a good tutorial and information is provided at http://blog.sqlauthority.com/2009/08/03/sql-server-introduction-to-sql-server-2008-profiler-2/

Upon executing the same action that produced the errors, I found that it was actually attempting to execute an insert statement for TableTwo instead of insert for TableOne.  Obviously, this means that there was an issue with the edmx file, and something is mapping correctly.

I inspected the mappings for both TableOne and TableTwo and did not see any incorrect mappings either in the designer view or via opening the edmx as an xml file.

Resolution/Workaround:

As a last ditch effort since the deletion and re-addition of the TableOne to the edmx did not resolve the issue and the sql statement was trying to execute against TableTwo, I decided to try deleting and re-adding TableTwo.  This caused any mappings to get regenerated which solved the issue and everything saved properly with no conversion errors of datetime2 to datetime.

*** All Content is provided As Is ***

Monday, July 11, 2011

Mini Profiler for MVC

So a collegue of mine, sent me this little gem my way so I want to share it with everyone.

Given that slow downs in MVC can be hard to diagnose if its an issue with a route, database connection, or even a little JQuery script the team at Stack Overflow create this highly useful utility for all to use called MVC-Mini_Profiler. 

The Pros:
  1. Collects stats for MVC Routes, Database connections, and JQuery posts
  2. Has a strong group backing the utility in terms of future enhancements/compatibilities
  3. Simple and easy to understand statics
  4. Can be implemented at most levels of the application including even down to the individual lines of code.
The Cons:
  1. Can be a little tricky to get working
  2. Displays statics only on the page that you have setup profiling
  3. On or off situation configured in application_beginrequest and application_endrequest

For best implementations I can clearly see the benefit for using this as part of the UAT and performance monitoring. But not necessarly something that would I leave in the application for production unless only certain accounts are given this feature as it over shadows the underlying application.

For more information and detailed usage instructions check it out at http://code.google.com/p/mvc-mini-profiler/.

*** All Content is provided As Is ***