Statistics
Visits: 99093
Page Visits: 132740
Active visitors (monthly): 5580
Feed Count: 49
Most visited page: Adding value as a technical analyst

Silverlight in Windows 8

I stumbled upon a link that talks about the end of Flash and Silverlight: http://debuggerdotbreak.wordpress.com/2011/11/11/the-bell-tolls-for-flash-and-silverlight-isnt-far-behind/

I do not think that Silverlight is dead yet. There are a lot of developers with WPF / XAML skills who are comfortable building Silverlight apps. It is preferrable to use Silverlight for line-of-business (LOB) applications within the Windows desktop environment. But, there are some conflicting messages about Windows 8.

The metro UI in Windows 8 is primarily targetted for the tablet users. Windows 8 cold boots in 4 seconds. Metro itself seems to be really good. But, what is bad for Silverlight developers is that Metro is based upon HTML 5 and not Silverlight. The Metro UI in Windows 8 has a browser that does not support any plugins including Silverlight. If you want to experience Silverlight apps in Windows 8, you will have to click on the desktop tile, and use the browser from there. So, using Silverlight for consumer applications is not a good idea. But for business apps, it is still a very good choice.

The other thing that is somewhat confusing is that Windows 8 does not run apps built for Windows phone. If you buy a mobile device and a tablet both running Windows, the chances are that you may have to buy two versions of the same app - one for the tablet and another for the mobile. This can lead to a slightly different user experience. Also, from a developers perspective, developers have to write different implementations for the mobile and the tablet.

This is early days as Windows 8 is available for developers to preview. I am sure a lot will change before Windows 8 goes live. Silverlight applications will run from the browser on the desktop tile. Also, Silverlight Out of browser applications will run as a tile from the Metro UI. So, Silverlight will live for sometime. I am looking forward for the next release of Silverlight - Silverlight 5 for more directions on its future.

 

Permalink | No Comments | Leave your comment
 

Service throttling issues in WCF hosted in Windows 7

My development environment is WCF 4 / IIS 7.5 / Windows 7 Professional. I have a WCF service with a single operation that sleeps for 2 seconds. My goal is to run 100 concurrent requests and ensure that all the requests complete within 2.1 seconds.

I started tinkering with service throttling. A service can have a service behavior which has throttling properties defined. So, I set the following parameters:


<serviceThrottling maxConcurrentInstances="100"
maxConcurrentCalls="100" maxConcurrentSessions="100" />

I went into perfmon and check the ServiceModelService => TimeOutService => Instances counter. It was showing as 10.

I assumed that there was some problem with the processModel. So, in machine.config, I changed the processModel to:


<processModel autoConfig="false"
minIOThreads="100" minWorkerThreads="100"
maxIOThreads="100" maxWorkerThreads="100" />

In perfmon, the instances counter was showing as 10. So, I went and checked the .NET CLR LocksAndThreads => w3wp => Total logical threads. This counter was showing somewhere between 30 and 40.  Again, very confusing.

After searching for more information, I found this forum post which suggests that Windows 7 has some limitations on performance tuning: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/449c17ca-1518-49f7-a58e-c043f0751bce/ . I wish I had checked this post earlier!

Permalink | No Comments | Leave your comment
 

Good articles in DNK

Here are some good articles in DNK for this month:
http://blogs.dotnetkicks.com/best-of-dnk/2011/11/02/best-net-articles-of-october-2011-fresh-off-the-presses/

I have been working on an interesting assignment involving Exchange web services (EWS). If you want to get started using EWS Managed API SDK, here is how you can:
http://blogs.dotnetkicks.com/vijayst/2011/11/getting-started-with-ews-managed-api-sdk/

I have been working on Silverlight and MVVM for the past few weeks. PRISM is an implementation of MVVM pattern. Here is the project in Codeplex:
http://compositewpf.codeplex.com/

Permalink | No Comments | Leave your comment
 

Data validations in Silverlight RIA applications

After a lot of reading, I have finally sort of figured out how to do data validations in Silverlight applications that use WCF RIA services.

Data validations should be performed both on the Silverlight application (that runs on the browser) as well as WCF RIA Service layer that runs on the web server. As of now, RIA applications support DataAnnotations as the main way of validating data. When a RIA service is created (say. CategoryService), a CategoryService.metadata.cs is also created. Within this file, a partial Entity class (Category) is defined. This is the place where you put all your data annotations.

When a Silverlight app is built, the Silverlight side entity classes are generated. This includes the data annotations defined in the server. Also, the class is derived from Entity abstract class which implements INotifyDataErrorInfo interface.

CustomValidation attributes are used whenever a validation requires access to the database. Here is a golden blogpost which describes exactly how it works: http://jeffhandley.com/archive/2010/05/26/asyncvalidation-again.aspx

CustomValidation when triggered from the Silverlight side is asynchronous. If you look at the above post, the service returns a Sucess. And then, if it finds any error, it asynchronously updates the ValidationErrors for the Entity. If the user does a Submit or Save before the async operation completes, the same validation should be performed at the server using the same CustomValidation attribute. Again, the above post is just amazingly cool as it explains how to do it.

There are other things you have to handle. The SubmitChanges of the DomainContext is asynchronous. So, any failures or success should be handled asynchronously in the callback method.

Validations using Data Annotations (in Silverlight or service) raise exceptions. In the Silverlight side, the framework knows how to invalidate the control state. When validations fail in the server, you will have to add the error to the ValidationErrors collection of the Entity class. This will invalidate the control.

While using data annotations, you will have to somehow let the ViewModel or the Entity know that there are errors. This is not automatically done.

Final tip: Do not try to roll your own custom framework using IDataErrorInfo or INotifyDataErrorInfo. It costs a lot of money. And you will have to do it at the service layer also.

Permalink | No Comments | Leave your comment
 

More rant on data validations for Silverlight applications using RIA

Models in Silverlight can be validated in three ways (atleast):

  1. Data Annotations
  2. IDataErrorInfo
  3. INotifyDataErrorInfo

Data Annotations are attributes attached to the model properties. Each of the attributes have a IsValid() method which fire an exception if validation fails. Because the validation logic is based on exceptions, it does not offer good performance - especially, if the model contains a lot of properties, all failing exceptions.

 IDataErrorInfo attempts to use an indexer to retrieve the validation error for a model property. IDataErrorInfo is simplistic - Only one error per property, and the error message can only be a simple string.

INotifyDataErrorInfo is Silverlight 4 way of handling validations. It can handle multiple errors per property and allows complex classes to be returned as error objects. It also notifies the UI that there is an error on the property. In this way, checks can be done async on the server, eg duplicate name checks.

How does RIA handle validations? When a DomainService is created, a DomainService.metadata.cs file is created. This file contains a partial <Entity> class which defines the metadata for the Entity. (Entity framework emits the other partial <Entity> class with data mappings and Key / Constraint information). This metadata class is where we can define the data annotations.

When we do a build of the Silverlight project, the metadata information from the RIA (with validation attributes) is combined with the entity class from the Entity framework to create a new <Entity> class within the Silverlight application. What is troublesome is that the <Entity> class derives from an abstract Entity base class which implements a lot of interfaces including INotifyDataErrorInfo. In my opinion, the auto-generated code is messy from a design view point. The auto-generated Silverlight <Entity> class has the same type name as the <Entity> class in the server side but a completely different implementation.

In my opinion, the validations using RIA is messy. I understand that we have to do validations both on the Silverlight end as well as the RIA service end. (Or am I mistaken?) I am not sure if the different approaches using INotifyDataErrorInfo and IDataErrorInfo are built to take care of this. In any case, with RIA, Data annotations seems to be the way to go.

But again, I am still exploring.

 

Permalink | No Comments | Leave your comment
 

Silverlight - Using MVVM pattern with WCF RIA services

I have picked up enough XAML, and Silverlight to write some good code for Silverlight applications. I prefer to use the MVVM pattern in the presentation layer, WCF RIA services for the service layer, and Entity Framework Code First for the data access layer. Getting all of this to work well together is some sort of nightmare for beginners. Sadly, there are no reference implementations either.

Entity framework and RIA uses EntitySet<T> as the collection class. I am more comfortable with ObservableCollection<T> or PagedCollectionView<T>. Even, the MVVM reference implementation - PRISM uses the ObservableCollection<T>.

For data validations, I prefer the IDataErrorInfo interface. This is more preferrable to Data Annotations. With RIA Services, the Entity class is auto-generated. So, I am not sure where I can put in my validations.

Another key problem with using MVVM model for beginners is the navigation. The Silverlight Business Application template solves this problem with the NavigationService class. If you are not using the Silverlight navigation framework and prefer to use the best practices from the PRISM framework, then navigation could be a nightmare. Try putting a simple "Are you sure to delete?" confirmation messagebox using the MVVM pattern.

Overall, learning MVVM, RIA, EFCF and putting them to work together is not the most pleasant experience as a developer. I hope to write a mini-reference implementation soon (A simple CRUD interface in Silverlight using MVVM, RIA, and EFCF).

Permalink | 1 Comment | Leave your comment

A series of jQuery posts

I am an editor in http://DotNetKicks.com - a twitter like site that allows .Net enthusiasts to submit the latest .Net stories every day. Here are some interesting jQuery posts that I have written in the last month.

Using the AJAX UpdatePanel Control with jQuery:
http://blogs.dotnetkicks.com/vijayst/2011/08/using-the-ajax-updatepanel-control-with-jquery/

Writing a simple jQuery plugin for Watermarks:
http://blogs.dotnetkicks.com/vijayst/2011/08/writing-a-simple-jquery-plugin-watermark/

Review of a jQuery plugin for formatting numbers:
http://blogs.dotnetkicks.com/vijayst/2011/08/numberformatter-a-jquery-plugin/

Integrating jQuery UI with your ASP.NET application:
http://blogs.dotnetkicks.com/vijayst/2011/07/integrating-jquery-ui-with-your-app/

A comparision of AJAXControlToolkit with jQuery UI:
http://blogs.dotnetkicks.com/vijayst/2011/07/ajaxcontroltoolkit-vs-jquery/

Learn jQuery in 5 minutes:
http://blogs.dotnetkicks.com/vijayst/2011/07/learn-jquery-in-5-minutes/

If you like these stories, feel free to kick it. (a friendly term for appreciating an article). 

Permalink | No Comments | Leave your comment
 

Shaping your technical career

There are close to 100,000 software developers joining the Indian IT industry every year. With so many developers, it is easy to get lost in the crowd. I have engaged myself with the IT industry for over 12 years now. I have seen the ups and downs of the industry. I have consistently done a decent amount of coding over the last 12 years. I have put together some of the things I have learnt over my career.

#1: Love coding

If you love coding, you will be interested in a technical career. There are lot of programmers who are in the industry who do not like coding. Their expectation is to become some sort of manager - a product manager, a project manager or a line manager. Everyone is welcome to do coding. But, if you are in for a technical career, you have to love coding.

#2: Application development

Application development is a rare thing. Most applications require maintenance or enhancements. There are lot of products available in the market like business intelligence products: Informatica, Microstrategy or business application tools like SAP, PeopleSoft. There are many developers who work with these products doing various system integration activities. The percentage of people who are involved in hard-core application development is very less. If you like coding, you should find yourself in an organization which does hard-core application development. You will enjoy it much better there.

#3: Choose your platform

There are lot of application development platforms - Microsoft.Net, Java (J2EE), Python, Ruby etc. Choose one and stick to it. Choosing a platform to work on is an emotional decision. It is not a logical decision. All platforms evolve over a period of time. You do not have to work in the best application development platform. You just have to choose one you are most comfortable with and stick to it.

#4: But we do not have projects

I have heard lot of managers saying that they do not have projects in say .Net. I want to narrate an incident that happened to me a few years back. At that time of the incident, I had over 5 years of application development experience. By mistake, I was associated with a project involving MicroStrategy. Soon, I became a BI expert. I remember talking to a manager about moving to a Microsoft specific team. My manager bluntly told me: "You cannot decide which team you want to work with. If the organization wants you to work in a Business intelligence (Data warehousing) team, you have to go to that team". You have to be flexible to the organization. But, not at the cost of your career. I wasted one year of my professional career with that team. But, it is not a complete waste. (humor intended!) I learnt a bit of data modeling - Star Schema design, ETL, BI reporting, and some analytics. It has helped to relate to people who are working in BI. I still have good friends who work in the BI world.

#5: Associate with people who appreciate your technical skills

There are lot of developers who are good in a specific technical discipline rather than posessing a broad range of technical skills. I have seen good programmers who are good in trouble-shooting but poor in design. I have seen some good designers who are weak in trouble-shooting. If you work for an organization where you need to posess a broad range of technical skills, ensure that you associate with people who appreciate your technical skills.

#6: Work on open-source projects

Work on open-source projects. This will help sharpen your technical skills. There are lot of people who will reach out to you. These  people appreciate your technical skills.

#7: Knowledge accumulation

Learning new things is good. But knowing a lot of things does not mean much. Knowledge accumulation is very much the equivalent of building your physique in the gym, or making a lot of fortune in business. Developing good analytical skills, decision making skills, prioritizing and planning skills is more interesting, more valuable than accumulating lot of knowledge. You can be a good technical guy without knowing a lot of things but be able to do a lot of things. Beware of the technical guy who ridicules others for not possessing some knowledge. Such category of developers are very common in India.

#8: Process but not too much of process

Process is necessary. But, if your organization talks only about CMMI, or Greenbelt, you are working for an organization which is an expert in grooming managers (and not technical people).

#9: Beware of colleagues

If you are a good technical guy and  you are in the early stages of your career, then you may not understand your colleague who has developed good organizational skills. Your colleague is on the way to become the biggest manager of all time. So, do not be influenced by him or her. The colleagues with good organizational skills appear to be good backstabbers. (humor, slightly sarcastic, intended) But, they are meaning well, especially for the organization. So, you should learn skills to handle these sort of people. But you should not get carried away by their "cutting-edge" skills to become one of them.

These are tips from my experience. As you can see, I have been an above average developer. So, these are tips for the above average developer. For the excellent developer, the career progression is clear and smooth.

I like to know your comments and what you think about the post.

Permalink | 2 Comments | Leave your comment
 
Commented by Vijay at 29-Aug-2011 12:09 PM

Thank you for your comments. You are right about learning a lot of new technologies. It helps us give a lot of options to the customers so that they can pick the best alternative.

Commented by Mitendra Anand at 28-Aug-2011 10:23 PM

Vijay, Nice column, I liked it.

To add to the list, I think in today's time a growing programmer must learn to read books on technology(s) he/she is interested in. Many programmers limit themselves to start with "Hello World" kind of thing and then they carry on the work as it comes with the guidence from web.

I particulary liked one of your statement -"I have seen good programmers who are good in trouble-shooting but poor in design. I have seen some good designers who are weak in trouble-shooting." I believe reading the subject helps in becoming good at designing and after you are exposed to the subject. It's the intution/gut feeling which makes you a good troubleshooter.