Lumia Music 2.0 is here
Your stunning Lumia Music visuals have got better. Now you can watch extra visuals, see and control the now playing song, and enjoy a seamless panorama experience.
Don't keep staring at album art while listening to music. Keep yourself entertained, show to your friends, and pimp your car sound system.
Ranked #1 on Music+Videos apps on multiple countries. Check the app website and download from here.

How to set panorama selected item
If you have used the windows phone panorama control in your applications, you will notice that you can't set the current active item (displayed panorama page). You can get it and you can set the default item that only affect the application start page. In some applications scenarios, it could be usefull to change the current active panorama item. For example in a music app, when a user choose a song to play, you may want to change the current active panorama item to a now playing page.I have found a workaround for this issue, which is to do the following:
1. Remove all panorama items except the one you want to be active.
2. Wait for 1 second by starting an empty StoryBoard with 1 sec duration.
3. When the storyboard is completed, return the removed panorama items.Note that the wait StoryBoard is nessecary for making the panorama control realize that there is only one item left so set it as active.
Why Entity Framework is better than traditional ADO.NET
In this post, I argue about why to use Entity Framework, instead of the old ADO.NET, LINQ to SQL. I'm not talking about NHibernate, which to some developers may seem a better alternative especially for more complex scenarios or enterprise solutions. What I'm explaining here is for the general need to access database in an easy and fast method.
Easy and fast to code
Using the Entity Framework, it's definitely apparent that it’s really easy to start the project, you create a diagram, point it to your database and choose the tables you want, and you have a ready to use typed objects that access the database.
Runtime Performance
Entity Framework is known to be generally faster than LINQ to SQL except that it has some overhead in initialization.
As some may argue that it is surely slower than accessing database using old DataReader and calling stored procedures which have a precompiled execution plan. This sentence is correct assuming that both will execute the same query. My argument is that by practice, I found that generally Entity Framework out performed our written SQL procedures for the following reasons:
- In large queries where the user has the option to use multiple filters, the EF excels because the query generated may contain only the filters chosen by user, instead of having a single procedure with all possible where conditions.
- In a lot of cases, doing paging in SQL takes much less effort to do in EF, so it encourages everyone to use it. While doing it the old way usually took more effort which caused us to only use it when we face a performance problem after testing on production data.
- Generally the SQL query generated by EF is better than our handwritten query (more optimized) except in rare cases where we spent long hours enhancing and testing our query performance. In these time critical cases of course you can always revert to calling a stored procedure the old way.
Other benefits
Using EF you get a lot of other benefits that includes: lazy loading, clean business logic code, automatic linking between entities loaded from different queries.
In the next post I'll talk about why you should use EF Code First.
I built this website using Orchard
Finally finished building this website using Orchard. It took me 1 week from scratch (on spare time only). This includes migrating my blog content from blogger (using the same URLs), customizing the UI and creating an amazing section for my Windows Phone Games.
Magic Flip
Flip your phone following an increasingly challenging orders like shake, tap, up, down, stop....
An action packed game, full of fun and addiction. Challenge your friends or cooperate with them.
No phones were harmed in the making of this game.
Price: 0.99$
Trial includes first 4 levels of the game, the full version includes the rest of 9 levels, challenge and party modes.
http://social.zune.net/redirect?type=phoneApp&id=5fabac8b-8d4a-4c95-81d7-48c6774abd3b
Farseer Physics Simple Samples
Just posted source code for new Simple Samples on Farseer Physics.
I've been working on porting it from XNA to Silverlight for a week. I believe the new version of Farseer Physics 3.0 fixes a lot of performance and stacking issues. Now I'm off to start my next physics game.
Magic Garden WP7 App Early Preview
An early preview of the trials I'm making for a Windows Phone 7 App: Magic Garden. The demo only shows the cool graphics effects that can be done with Silverlight on WP7 and the potential for this App as a casual multipurpose game.
Any feedback and suggestions are welcome.
Getting started with Windows Phone 7 development
I started playing with WP7 a while ago and have stumbled upon many resources and blogs, so thought I’d gather all the useful resources that I found in one place in order for new comers to get the most of it.
1. Download and install the development tools
These are the visual studio tools to be able to create and build the new Silverlight and XNA phone projects.
http://www.microsoft.com/downloads/details.aspx?FamilyID=c8496c2a-54d9-4b11-9491-a1bfaf32f2e3&displaylang=en2. Check the application platform overview
This will give you a quick look at the full phone development ecosystem starting from the tools, the phone runtime, the developer portal, and the phone market place.
http://msdn.microsoft.com/en-us/library/ff402531(v=VS.92).aspx3. Check the UI design guidelines
If you are interested in UI and Design, you should read this full document. If you like to code more then you must get a quick look at this document and skip reading whenever you’re bored. But generally it’s a must read for everyone.
http://go.microsoft.com/?linkid=97132524. Read this post about WP7 Application Execution Model
This is a very useful 3 parts blog post about the application execution model and the ways to save the application states when user navigate between multiple WP7 applications and use the back button.
Part 1 , Part 2 , Part 35. Check this full list of links
This page has a very long list of WP7 related posts/components that you may want to use in your applications.
http://social.msdn.microsoft.com/Forums/en/windowsphone7series/thread/756c8d2e-4a3f-43cf-a6ed-28fa44a27ff76. Keep reading WP7 blogs
There are a very valuable updates published here, so keep in touch with this page every few days.
http://windowsteamblog.com/windows_phone/b/wpdev/I hope this page is useful for new WP7 developers.
Holy Bible Reader
Finally created the website:
http://www.holybiblereader.com
A usable website for reading and studying bible from PC or mobile.
Hosted at home, developed with ASP.NET MVC 2.0 with UI features using blueprint css framework and jQuery.
Object reference not set to an instance of an object
The most popular .NET exception ever
If you have worked with the .NET framework for some while, you will notice that object reference is the most popular exception you will ever get. You can see this in Google trends as this will be the most exception searched for on Google. There are some other exceptions though less popular than object reference like “Index out of range” and “Input string was not in a correct format”. I’m going to talk below about why we get these exceptions so often and how to prevent them.
Why do we always get it?
My philosophy in life is that when you get these kind of exceptions from calling a method in a component (which could be a class library, a web service, or another class in your own project). This means that the developer who created it, didn’t care enough to check for your input. And that your wrong input has probably caused some damage to the stability of this component. And this is all because of the optimistic approach taken by component developers.
When you call a method in a class from the .NET Framework you never expect it to throw such exception. You expect it to through an Argument Exception in case you provided a missing parameter. Because it was designed carefully to only expose certain types of exceptions. And to always maintain a consistent state not affected by the abusive parameters used by callers.
When you are designing a new component, you should put a big amount of efforts checking for input, validating parameters, and handling errors. You should document what are the expected exceptions that can be thrown from each method and stick to them. And when an unexpected exception happen in the middle of executing something, the component state should be rolled back to the state before the current method is executed, cleaning up any incomplete values that may have been resulted.
Doing anything less, will cause your components users to have a lot of troubles tracing what have they done that caused these exceptions. And maybe try to debug your code, if possible, to know which parameter is wrong. And if your code is not available to debug, they’ll try to contact you. And if you are not available, they’ll end up ignoring your component and trying another one or building their own from scratch.
Good habits to prevent it
- Always check external variables you get from user input, database, external web service and other system modules, for not being null or DBNull. Practically check any variable that was not declared in the scope of the current method.
- Never access the zero element of an array without checking the array length. Usually accessing array should be through a loop which doesn’t expose you to the array length problems. Access the first element usually means something wrong in your code design. Why did you pass an array to a function that only access the first element?
- Always remember that string can always accept null as opposed to other value types like int, float, double, char which don’t accept null value unless marked as Nullable.
- If you checked some parameters and encountered a wrong value that was not supposed to be passed to your method, you should always throw an Argument Exception to indicate this to the caller developer.
- An extra check will never hurt anyone or cause any performance downgrade, but a missing check will cause you a lot of trouble.
That’s it for now, wishing you a better maintainable coding style.
- ADO.NET
- ads
- ajax
- app
- asp-net
- azure
- best-practices
- c
- cards
- cloud
- CMS
- code
- code-project
- connect4
- construction
- Data Access
- Entity Framework
- error
- exception
- facebox
- farseer
- findcontrol
- games
- handlers
- http
- javascript
- jquery
- library
- LINQ
- microsoft
- mojave
- net
- Orchard
- panorama
- physics
- sds
- servercomponents
- service
- silverlight
- solitaire
- spider
- uncategorized
- vista
- wcf
- Web
- windows
- wp7