Saturday, 24 December 2011

Windows RunTime–Windows 8


With the launch of Windows 8 comes a new disruption for developer they call it the Windows RunTime(WRT). A decade ago we worked on Win 32 API as years progressed .NET came in & with it came a host of easier language C# , VB.NET.  Microsoft has continued to keep Win 32 API usable via .NET via P/Invoke and some directly via .NET with additional supportability.

There has been an oblivious thought process to keep Win 32 alive since its early days till now & reason to , Architecturally speaking the paradigm shift to richer UI with slate, tablet as next gen users, it was poised to look at something new faster using Win 32 native system via inbuilt plumbing for the .NET user enabling them to build Metro Style Application.

The need of the hour has been to simplify Win 32 layer to introducing WRT layer simplified and can be used by C#, VB.NET developer.

To know more about WRT refer to these session


Key Take away

1) It is not based on .NET, only exposed to it (a bit like COM interop, but much more seamless... e.g. no interop assemblies)..

2) At the lowest level, WinRT is an object model defined on ABI level. It uses COM as a base (so every WinRT object implements IUnknown and does refcounting), and builds from there. It does add quite a lot of new concepts in comparison to COM of old, most of which come directly from .NET - for example, WinRT object model has delegates, and events are done .NET-style (with delegates and add/remove subscriber methods, one per event) rather than the old COM model of event sources and sinks. Of other notable things, WinRT also has parametrized ("generic") interfaces.

3)One other big change is that all WinRT components have metadata available for them, just like .NET assemblies. In COM you kinda sorta had that with typelibs, but not every COM component had them. For WinRT, the metadata is contained in .winmd files - look inside "C:\Program Files (x86)\Windows Kits\8.0\Windows Metadata\" in Developer Preview. If you poke around, you'll see that they are actually CLI assemblies with no code, just metadata tables. You can open them with ILDASM, in fact. Note, this doesn't mean that WinRT itself is managed - it simply reuses the file format.

4) Does WRT interact with CLR – No Something which I am not sure still hunting answers but my hunch is no.

Couple of other important links

From the looks of WRT its likely to future programming considering the form factor is the slate & the tablet, I’m quite sure the WPF to build the Metro Style UI would be sucking on performance big time so the brain wave why don’t we rewire & use com with win 32 to do the same job.

How long does this idea go well with the developers is shaky.

Wednesday, 21 December 2011

Managed Extensibility Framework in .NET 4.0


Had a lot of catching up to do on .NET 4.0 & .NET 4.5, I stumbled upon the Managed Extensibility Framework (MEF) new to .NET 4.0.  A good start to understand the MEF would be to run through the channel 9 series of videos at

In case you want to run through a sample look at Visual Studio 2010 Training KIT -

MEF derives a lot of its thought process of the classical design problem statement “ My client application need certain features down the line I’m sure there are licensed at a premium price but I’m not sure if I will be include this in my deployment kit”.

Or in other word look at the USB its plug an play can accept any kind of devices on the fly as long it adheres to USB standards.  This is a classical interface based designing where one may go define a standard operating interface for USB ( its related operations).

Obviously if a designer intends to solve this problem the interface design way he/she would publish a standard interface have every new component implement this interface & write the binary locations in the config file and have the code load up this assembly.

Interestingly MEF encapsulates the assembly loading part but it does have all components honor the Interface Definition Commitment no moving from this.

What it means for the .NET world I can add new functionality to the client application without having to change the client codebase, just copy paste the new assembly which implements the new interface in the application bin directory and you are pretty much done.

In short the key take away from .NET developer

  • Use MEF pattern for extensibility of components, which can go in as separate deployable unit on demand or at a later stage.
  • You can go Dependency or IOC this is a lot cleaner
  • Singleton is good to use in the application what about scenario where I may want to move to Multi instance if lifetime management behavior is embedded in the core application I need rewrite it would be good to abstract the lifetime management outside of the application by going MEF using PartCreationPolicy
  • Dependency Resolution: Good part of under the hood MEF has been written to load up all the related dependencies to the new type loaded.
  • Modularity: MEF allows for modularity by allowing you to separate functionality into different modules and load them dynamically as needed.  Imagine a large application that has ten menu items, but users typically may only go into one.Only when the user needs a piece of functionality will their application download the extension and make it available. This allows them to get up and running faster and conserves resources by only supplying what is needed.

In short life for a .NET developer is highly simplified with MEF as compared to the earlier options for building composable apps. Leaving with – a good read for a finish.

To make things better in scenarios one can end up using Lazy Loading as the data loading can be deferred to point of usage. Multiple Implementation Pattern of  Lazy Loading

  • Lazy Initialization
  • Virtual Proxy
  • Ghost
  • Value Holder.


Using MEF for unmanaged world is still a thought , some answer could be reasoning out of introduction of Windows Runtime in Windows 8 which in a way is more closer to un managed world, so there is likely possibility in the future using Windows Runtime with MEF.

Saturday, 17 December 2011

Cloud - The Happening

I was walking by a cafe in New York in the nineties and could'nt help noticing my dear indian friend who was about to have a coffee was slightly hesitant to use his credit card in the small outlet. About 15 years down the line I see the same outlet and the so called magnifiicent use of credit cards is roaring. What does this have to do with Cloud well similar situation lets talk 15 years down the line, companies confidence in using Cloud will only go up.
Like credit cards has seen its phase from non acceptance to daily cant live without item so will cloud.
Most companies today have gone past the definition phase of cloud and thats good. Most SI, software consulting companies have begun to invest a huge in building cloud expertise. While SI incubate and build the capacity I think they are also cognizant to the fact that the cloud discussions with the customer will be very different.  What's is it in for the SI who brings the organizations to cloud a lot , one time migration cost, annuity based business for next 20 years.
Here comes the catch - The discussions with CxO's of the companies is going to very different somewhat like "Can you take my an entire ecosystem into cloud in agile manner within next 6 months & reduce my IT cost by 30% YOY", What does mean to the SI " moving a hybrid ecosystem to a hybrid cloud and taking complete ownership of the SLAs and making dollars at the end of the day. While cloud provider make there bit on low hangers its the SI who will make the bulk of the money and pass a smaller pie to the Cloud provider.
The discussion is really not going to be around "Can you move 1 application to azure , aws etc..." Its a one bullet agenda "Can you move my ecosystem to cloud and give a 30% savings on IT costs, so that I go home on a larger bonus".