Statistics
Visits: 105081
Page Visits: 139145
Active visitors (monthly): 5364
Feed Count: 45
Most visited page: Adding value as a technical analyst
Archive : Aug 2011

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.

A minor design flaw in Microsoft AJAX library

Microsoft AJAX Library is a good javascript library for building AJAX components, behaviours, and controls. It is widely used by AJAXControlToolkit. Microsoft AJAX Library has a central class called PageRequestManager. A singleton object of this class is initialized when you put an UpdatePanel in the aspx page.

PageRequestManager provides events which you can handle. A common use is to cancel the AJAX request if another AJAX request is running. This is the common structure of javascript code that uses the PageRequestManager.


var prm = Sys.Webforms.PageRequestManager.get_instance();
prm.add_beginRequest(function() {});

There are two events that are raised before a AJAX request is invoked: initializeRequest, beginRequest. The request body can be got using code like this:


var prm = Sys.Webforms.PageRequestManager.get_instance();
orm.add_initializeRequest(
   function(sender, args) {
      alert(args.get_request().get_body());
   });

I have a requirement where I want to modify the values of a textbox when some conditions are met. This should be done after the user clicks the button but before the AJAX request is invoked. I have multiple buttons / GridView links in the page which are AJAX enabled.

I hooked into the PageRequestManager initializeRequest(). I modified the textbox values. However, the server did not get the modified values. It appears that the request body is prepared before the initializeRequest() event is raised.

The worst part is that the library does not allow me to modify the request body using a simple API. Sys.Net.WebRequest has a method to set the request body using the set_body() function. But, there is no programatic API to set the value of the textbox using an ID or name.

One more reason why the Microsoft AJAX library did not become popular!

Permalink | No Comments | Leave your comment
 

LiteBlog - Subtle error while editing post twice

Last week, I edited an already published post. I published it. It worked fine. Then, I tried re-editing the post a second time. I got an exception. The error suggested that there was an error in updating the Archive.xml file.

On further analysis, I figured out that the publish date was showing up as Jan 1, 1900 while publishing the post (for the second time). I remember this was working fine. But, I have never tried editing and reediting a post.

I put a breakpoint on the Compose action of the Post controller. While editing for the first time, the breakpoint was hit. The post was published fine. While doing another edit (the second time), the breakpoint was not hit. I suspected a caching problem.

I have not enabled OutputCache in the server. So, IE was caching the Compose page very cleverly. I verified my assumption by using Fiddler. Fiddler suggested that the browser was serving the page from the cache.

So, I added one line of code to prevent browser caching:


Response.Cache.SetCacheability(HttpCacheability.NoCache);

It is working fine now. A published post can be reedited and republished as many as times as you want. (hopefully in all browsers).

Permalink | No Comments | Leave your comment
 

DotNetKicks! and this blog

I have a new blog location at http://blogs.dotnetkicks.com/vijayst. I will write longer and well researched blogposts in this new location.

I will use this blog (vijayt.com) for writing very short tips. These tips will usually be a distilled version of the discussions in Asp.net forums - http://forums.asp.net. I will also use this blog as a test bed and a live application for my blogging application - http://liteblog.codeplex.com

If you have not tried out kicking in http://dotnetkicks.com (DNK), try it. It is free!. DNK provides the popular stories of the day in the home page. These popular stories are usually articles and blogposts from .Net evangelists from all over the globe. Happy kicking!

Permalink | No Comments | Leave your comment
 

Usability issues with jQueryUI datepicker widget

Datepicker is a one of the key widgets available in jQuery UI. For a demo, check the link: http://jQueryui.com/demos/datepicker

When you click on the textbox which is datepicker() enabled, it should open up a calendar. When the user selects a date, the calendar should go away. I have noticed that the widget has a few usability issues.

In IE 8+, when you click on the textbox and select a date from the calendar, the calendar does not go away. This is somewhat irritating. The workaround to this is that the user clicks on the page (other than the textbox).

In Chrome, the usability issue is slightly subtle. On selecting the date from the calendar, the calendar does disappear. But, what if the user wants to change the selection? When the user clicks the textbox again, the calendar does not popup.

My suggestion to developers is to show the button beside the textbox. This is available in the datepicker using the options provided. The default text in the button is "...". This can be changed. Also, for the UI designer, there is a neat option to embed an image within the button. The code to enable the button is shown below:


$('input[name$=txtDate]').datepicker({
    showOn: 'button',
    showButtonPanel: false,
    buttonText: 'Show'
});

 

Permalink | No Comments | Leave your comment
 

Localization of Webform applications in multiple languages

Usually, web applications should be available in multiple languages other than English. In this blogpost, I am going to walk over creating a sample application that will be localized in French and Dutch. Usually, the preferred language is picked from the user's browser settings. To make it a little tougher, we will allow the user to switch languages at runtime. To enable runtime switching of languages, we will add three link buttons in the master page.


<div style="background-color: #cccccc;float:right;">
    <asp:LinkButton ID="btnEn" runat="server" Text="en" CommandArgument="en" OnCommand="SetCulture"></asp:LinkButton> | 
    <asp:LinkButton ID="btnFr" runat="server" Text="fr" CommandArgument="fr" OnCommand="SetCulture"></asp:LinkButton> | 
    <asp:LinkButton ID="btnNl" runat="server" Text="nl" CommandArgument="nl" OnCommand="SetCulture"></asp:LinkButton> 
</div>

Localization is providing a placeholder for text in multiple languages. The text comes from a resource file. Asp.Net provides multiple ways of doing localization: implicit and explicit. In Default.aspx, we enable implicit localization. We allow the text within a label with ID lblImplicit to come from resource files. The code for the label has a meta:resourcekey="" attribute attached to it:


<h2>
    Culture Demo - Implicit Localization
</h2>
<p>
    <asp:Label ID="lblImplicit" runat="server" meta:resourcekey="lblImplicit" Text="Implicit Localization"></asp:Label>
</p>

In implicit localization, the text comes from a resource file defined under App_LocalResources folder. The resource file has the convention of .aspx..resx. The default resource file for default.aspx is default.aspx.resx. The resource file for french is default.aspx.fr.resx. Create resource files for each supported language. Within the resource file, use the .Text to define the text for the label. The french resource file looks like:

We can set explicit localization for About.aspx (just to try it out). Explicit localization looks for resource files under App_GlobalResources. In this folder, resource files are not organized by aspx page names. You can create a default resource file of Messages.resx. In the About.aspx, we can create a label to use Message1 from Messages.resx as follows:


<h2>
    Culture Demo - Explicit Localization
</h2>
<p>
    <asp:Label ID="lblExplicit" Text="<%$ Resources: Messages, Message1 %>" runat="server"></asp:Label>
</p>

In the above label, the text is available within a tag. It has a Resources: keyword. Both the Resource file name as well as the Key name is provided (delimited with a comma). The french resource file for Messages will look like Messages.fr.resx. The dutch resource file, Messages.nl.resx looks like:

 

Now, we are ready to write some code to make all of this work. When we are clicking the link button in the master page, the SetCulture event handler is called. All we do in the below code is set the Session["Culture"] variable to the selected language. Also, the page is redirected to. This will ensure that the selected culture will set in the reload.


protected void SetCulture(object sender, CommandEventArgs e)
{
    Session["Culture"] = e.CommandArgument.ToString();
    Response.Redirect(Request.RawUrl);
}

Every page has a method - InitializeCulture(). This method is triggered in the Page lifecycle ahead of all events including Page_PreInit(). This is one reason that the page is reloaded again. In InitializeCulture(), we pick the language setting from the Session variable. Then, we set the UICulture for the current thread. This will ensure that the right resource files are picked for the current request.


protected override void InitializeCulture()
{
    // When the user comes to the page for the first time
    if (Session["Culture"] == null)
    {
        Session["Culture"] = "en";
        Session["OldCulture"] = "en";
    }

    // Set the UI Culture here

    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo((string)Session["Culture"]);
    UICulture = (string)Session["Culture"];
    base.InitializeCulture();

}

Finally, there is some code to enable / disable the link buttons in the Page_load of the master page:


protected void Page_Load(object sender, EventArgs e)
{
          
    string culture = (string)Session["Culture"];
    string oldCulture = (string)Session["OldCulture"];

    // Disable the button in current culture
    // This is required if user goes to some other page
    // Page is populated with controls.
    LinkButton newBtn = FindControl("btn" + culture) as LinkButton;
    if (newBtn != null)
        newBtn.Enabled = false;

    // if old culture is different
    // This happens when the user clicks on any of the link buttons
    if (culture != oldCulture)
    {
        // disable the button for the current culture
              

        // enable the old button and reset oldculture  
        LinkButton oldBtn = FindControl("btn" + oldCulture) as LinkButton;
        if (oldBtn != null)
            oldBtn.Enabled = true;
        Session["OldCulture"] = culture;
    }
}

One last thing to note, I have used a baseclass for Page - CultureDemo.MainPage. This class overrides the InitializeCulture method. All pages in the CultureDemo application derive from CultureDemo.MainPage instead of System.Web.UI.Page. This ensures that all page and all requests have the right language setting. The complete application is available in the zip file: CultureDemo

Permalink | No Comments | Leave your comment
 

Aeroplanes, Design patterns, and People

Yesterday, I attended an interview where I was asked to design a air-traffic control system. I designed one and the interviewer was sort of happy. On the way back home, I reflected on the interview. My thoughts went to my favorite topic of innovation.

Without innovation, we would not have a aeroplane. Innovation is about finding something new and perfecting it. But, of late, I have to admit that innovation is not everything.

Today, air travel is safe. This is because of the efforts of well-trained engineers making a Boeing or an Airbus. It is because of a lot of well-trained maintenance staff who do all the checklists to ensure a safe travel. Every organization needs a handful of innovative people and a whole lot of process-centric, skilled people. A software product is no different from an aeroplane.

A software product must be new and satisfy a valid customer need. Innovative minds should work together to come up with a new product idea. But, once an idea is formed, we follow all kinds of design patterns, to ensure that the software product is maintainable and usable. We follow good processes to ensure that the software product satisfies the customer need. We need both innovative people, skilled people, and process-centric people to come up with a good software product.

There is also an other side to it. Innovative people and process-centric people specialize in what they do. Rarely, they understand each other. Why is that?

Innovative people need to break a few rules. That is when you come up with something new. Innovative people understand that rules and processes exist to satisfy a need. There could be multiple ways to meet the need. So, the existing process is just a convenient or effective way to do a certain thing.

Process-centric people are a different breed. They like to do things as perfectly as possible. A process, once defined, should not be broken. It can be replaced by something new and better. They are experts in following process.

I belong to the breed of people who like to try new things. I believe that nature evolved because of trial-and-errors. Evolution is not planned. If it were planned, monkeys would not have tails. I also believe that there exists a framework to do the trial and errors. If trial and errors were chaotic, there would not be any gravity. (I believe gravity evolved). OK, I am sure that you would have lost me by now. So, I will cite a concrete example.

A lot has been invented by trial and errors. Before Edison came up with the electric bulb, he failed more than a 1000 times. The framework of coming up with an invention through trial and errors is just plain logical analysis. The above examples are given to justify my stand of trying out new things.

I definitely do not belong to the category of process-centric perfectionist. But, I do follow process. Over the past few years, I have found one major weakness of the process-centric perfectionist. The process-centric perfectionist extend their process-centricity to human behaviour. They demand a level of behaviour among their co-workers that is sometimes simply annoying.

Is it not common to find managers who appreciate well written emails, polished and respectful conversation more than well-written code? Being a person with an innovative bend, I do not have much rules. But, I have one rule which I will definitely follow: Avoid the process-centric perfectionist. If you have to deal with one, deal with him or her with utmost seriousness.

This was the train of thoughts that came to me on the way back from the interview. I felt that it was worth a post.

Permalink | 1 Comment | Leave your comment
 
Commented by Mitendra at 14-Aug-2011 07:52 PM

Vijay, Nice one :)

I love this line "Is it not common to find managers who appreciate well written emails, polished and respectful conversation more than well-written code?"

 

Keep writing!