Skip to main content

Posts

Showing posts from February, 2010

A 10 minute ASP.NET MVC Twitter Search App – Using a Duck Typed (dynamic) View Model using ElasticObject

The objective of this article is to demonstrate how to use duck typed (dynamic) view models with ASP.NET MVC, especially when you work with fluid data stores like XML. As we are using .NET dynamic features, you’ll need VS2010 beta or RC to work with the samples. Full source code is available, but I’ll recommend you to go through the article before you download.[v] Download Twitter Search AspNetMvcDemoAppThe ApplicationAlright, to start with, have a look at the application screen shot below. It is a simple Twitter search app in ASP.NET MVC, that can show you the latest tweets about what you search for. The ControllerHave a look at my controller. I just created an ASP.NET MVC 2 application in VS2010 and added references to Microsoft.CSharp.dll and AmazedSaint.Elastic project (included in the download above). AmazedSaint.Elastic namespace contains my ElasticObject implementation, I blogged about previously. Basically, ElasticObject can be used as a fluent dynamic wrapper to work with dat…

Introducing ElasticObject implemented using .NET 4.0 dynamic features - An easier way to work with XML in CSharp, A Smarter Cousin of ExpandoObject.

Source Code? – Get it from http://elasticobject.codeplex.com/This is an intro post on the ‘ElasticObject’ class. First of all, let us see what exactly the ElasticObject implementation is capable off. After that we might touch the implementation details. To start with, here are few scenarios you can use ElasticObjectAn easier, fluid way to work with data formats – like XML and JSON. Presently, we’ve some support for XML. Cleaner code though it is duck typed A hierarchical way to maintain loosely typed data. Note: A Quick Clarification after reading few tweets - ElasticObject is not a class in .NET BCL, it is something that I’ve implemented, and you can get the code by clicking the above link :)1 – You can create multi level Dynamic objects automatically, like thisElasticObject supports creating hierarchical dynamic data structures. For example, consider this code.2 – Then, you can simply convert that to XML using the ‘>’ Conversion Operator In ElasticObject implementation, several o…

Silverlight in Windows Phone 7 and beyond - Why Silverlight is going to be ‘THE’ development platform

Remember the “Three Screens and a Cloud” phrase coined by Ray Ozzie? To understand why it is such a brilliant vision, just take a step back and see what percentage of your time you end up spending with these three screens – your PC, your phone and the Television hanging in front of you. And suddenly, you’ll realize that all recent announcements from Microsoft – be it Azure, Live Services, Bing, Silverlight, Windows 7 or the brand new Windows Phone 7 Series – are just individual pieces of a larger puzzle, already envisioned by Microsoft.In that sense, Windows Phone 7 device is not just an individual piece you are going to carry with you. The “Life in motion” term coined for describing the user experience in Windows Phone 7 says it all. And probably that is exactly why Steve Ballmer is almost sure that the software is what matters in a high volume phone market. From the TechCrunch interview with Steve, he mentioned,Microsoft still thinks a software play is right for them in such a high …

Top 5 Common programming mistakes .NET developers must avoid !!

Some time back, I asked a question in Stackoverflow.com, about common programming mistakes .NET developers must avoid. The response was awesome, to say the least. I’m just listing down the top 5 developer crimes I picked, from the answers I received (regardless the votes). 1. Breaking the stack unnecessarily when you re-throw an exceptionThis a pretty ‘old thing’ - but surprisingly, still a very common mistake. As TheSoftwareJedi mentioned, you don’t really need to break the stack while throwing exceptions. I’ve done this myself when I was a beginner - and I’ve seen this more often than anything else when I do code reviews these days. To clarify the point - What is the difference betweentry { ..} catch (Exception ex) { throw ex; }and  try {..} catch(Exception ex) { throw; }  ? And when you lose the stack trace, you can’t debug your app – and even worse, you can’t log your error details properly to your error log.The MSDN guidelines on exception handling clearly statesDo not rethrow b…

What is LINQ to Events a.k.a RX Framework?

I received a mail some time back, asking me to “clarify in simple words the concept of LINQ to Events”. This is a quick post on LINQ to Events a.k.a the RX Framework, and the objective of this post is to high light some of my previous posts on the same topic. NET Rx team (this is not an official name) found that any push sequence (events, callbacks) can be viewed as a pull sequence (as we normally do while accessing enumerables) as well – or they are Dual in nature. In short observer/observable pattern is the dual of enumeration pattern.So what is cool about about this duality?Anything you do with Pull sequences (read declarative style coding) is applicable to push sequences as well. Here are few aspects. You can create Observables from existing events and then use them as first class citizens in .NET – i.e, you may create an observable from an event, and expose the same as a property.As IObservable is the mathematical dual of IEnumerable, .NET Rx facilitates LINQ over push sequences…