Posts

Regular Expression: Support for all languages

Introduction: One of my friend came across a situation where I need to restrict a text control to support only alphabetic. So, we tried with very very simple regular expression; /^[A-Za-z]*$. Now the question arises whether this control also supports any other languages? If I change my setting to French, will this control supports? Solution: The above mentioned regular expression is not generic enough if it wants to match all those characters that are used in languages like French. /^[\p{L}-. ]*$ This says: ^ -: Start of the string [ ... ]* -: Zero or more of the following \p{L} -: Unicode letter characters - -: Dashes . -: Periods -: Spaces $ -: End of the string Keep coding... :-)

Event order in Client-side

If an element and one of its ancestors have an event handler for the same event, which one should fire first?” Not surprisingly, this depends on the browser. The basic problem is very simple. Suppose you have a element inside an element ----------------------------------- | element1 | | ------------------------- | | |element2 | | | ------------------------- | | | ----------------------------------- and both have an onClick event handler. If the user clicks on element2 he causes a click event in both element1 and element2. But which event fires first? Which event handler should be executed first? What, in other words, is the event order? Answers •Netscape said that the event on element1 takes place first. This is called event capturing. •Microsoft maintained that the event on element2 takes precedence. This is called event bubbling. The two event orders are radically opposed. Explorer only supports ev...

Pair Programming

Background I have been a follower of pair programming for a quite some time. Every time I try to advocate the use of pair programming I come across few faces who raise their eye brows (outside friends) and I get an impression that they are thinking what a waste of time. But I believe that if you use pair programming judiciously it can be a great asset. Lets see why I tend to lean heavily in favor of pair programming. Does pair programming really work I came across pair programming as a term way back in 2005/2006 when I had attended a BDotNet user group meeting. There was a presentation by a person from ThoughtWorks (I guess). That point of time I thought it is a waste of time. But I actually experienced it personally from last 6 months or so for some of the complex task in few of the Respond sprints. I got to work closely with my counterparts in UK. Ever since then I have been a big time follower of pair programming. It is a proven fact that two brains working on a problem are far bett...

Lazy Loading in Entity Framework

ets write a simple query to fetch the top 20 employees from the Northwind database and count the number of orders placed by each employee. NORTHWNDEntities context = new NORTHWNDEntities(); var employees = context.Employees.Take(20).ToList(); foreach (Employee employee in employees) { Console.WriteLine("Total number of order by employee : {0}", employee.Orders.Count); } We start off with creating the ObjectContext which is NORTHWNDEntities in our case. We filter the 20 employees using Take method on the employees entity collection. Then we loop over the individual employees and display the count of Orders to the console window. By default Entity Framework 4 enables the Lazy Loading feature. Because of this there are multiple hits to the database server. The initial query which filters the 20 employees is executed when we start iterating over the loop. And then for each employee a separate query i...

Agile Specifications

A very good link about the Agile Specifications... http://agileconsortium.blogspot.com/search/label/Agile Spec

Tech-Ed 2011

Image
Recently, I attended Microsoft Tech-Ed 2011 from 23rd March - 25th March. Microsoft Tech-Ed is the primarily technical and networking event for tech enthusiasts which is mainly focused on current and upcoming or latest Microsoft releases such as technologies, tools, platforms and services. Tech-Ed held at the The Lalit Ashok Hotel , Bangalore. I didn’t think that I will be attending the Tech-Ed 2011 this year but my manager has opted me even I was busy with my some of project deliveries. But, I finally managed got it (Thanks to my manager and team mates for th support). I started from my home at 10 AM and reached The Hotel Lalit Ashok at 11.15 AM, I thought it was too early, but sorry, I was wrong, too many techies are already roaming around. I did my registration along with my office mates first and looking forward to attend and make it fruitful. There was a session on " The NextWeb ". Which was very interesting session from tech evangelist Harish Ranganathan. The NextWeb i...

Creating Custom Action Filters

The possible uses for action filters are as varied as the actions to which they can be applied. Some possible uses for action filters include the following: Logging in order to track user interactions. "Anti-image-leeching" to prevent images from being loaded in pages that are not on your site. Web crawler filtering to change application behavior based on the browser user agent. Localization to set the locale. Dynamic actions to inject an action into a controller. Implementing a Custom Action Filter An action filter is implemented as an attribute class that inherits from ActionFilterAttribute. ActionFilterAttribute is an abstract class that has four virtual methods that you can override: OnActionExecuting, OnActionExecuted, OnResultExecuting, and OnResultExecuted. To implement an action filter, you must override at least one of these methods. The ASP.NET MVC framework will call the OnActionExecuting method of your action filter before it calls any action method that is marked...