Pages

Showing posts with label Programming - General. Show all posts
Showing posts with label Programming - General. Show all posts

Wednesday, March 3, 2010

Software Development: 80-20 principle or edge case

Few days back I was reading an article of David S. Platt on MSDN. David was taking about something like 80-20 principle. As per his writing, we can make happy 99 people but not the 100th person. In his first article in MSDN he stated a feature (designed for 110th user but not for another 99 users) to dock the file menu bar as bug.

In his second article, getting some arguments against his first article, he reiterated again about the point edge cases where only a few people will be benefitted. These two articles are must-read for people who is working in management as well as for developers.

Monday, September 28, 2009

Google Wave: Email is too old and need to replace or re-engineered.

This is my first article on Google technology. I am always a fan of Microsoft technologies. But recently watching a video on Google Wave I can't help myself writing on it. I can't remember when I last astonished seeing something technically innovative. But I did so watching the power of Google Wave. Ok enough with my personal view. Let's dig deep into Google Wave. But before that, let's deal with the major problem with current email system.

Problem with current email system

The current email system was introduced few decades ago. So if you ask yourself that if the email was introduced on year 2009 then how it would be? Definitely it would be more smarter and interactive. And that's Google wave is. Email is a kind of client based (content) management system rather than sever based. Though server works to route and temporarily (sometimes permanently) store email, the email is finally downloaded by client and managed on client machine. As email is sent back and forth, different version of the same email (or thread) is stored in the different user's PC. so information (contained in the email) is disseminated in different locations of different versions. As shown in the following image, currently email server's main role is to relay the messages. Though nowadays email provider allow us to store mail on the mail server but client also may have the copy of the same mail on his desktop/laptop. So the email is not managed in a central location and multiple version of the same email exists.

image

Figure 1: General view of How current email system works.

 

How to solve?

Now the question I may ask you if email was introduced on the year of 2009 and if you were responsible to design the system what you would be your first consideration? If you would ask me the question I would reply that I would keep the email as a single entity and all users would work on a single instance. Currently recipients of the email have their own copy and work on that local copy. But if the copy would stored in the server and users would work on that single server copy then it would be easier to manage and keep track of. This would also ensured that the email doesn't have multiple copy. So the information is not disseminated. The concept is a kind of "email is a single content stored in a single location and multiple people are working on it". So here collaboration is a kind of multiple people working on a single entity. So email need to be a single instance and need to be stored in a single location and multiple people should  interact/collaborate with it. The following figure depicts the idea.

 

image

Figure 2: How email could be managed as a shared content.

 

We developers are used to work with version controlling system (like, SVN, Visual SourceSafe etc). The concept shown in figure 2 is something like that.

 

What Google Wave does?

In simple Google Wave is new collaboration system. It includes features of email, instant messaging, documenting and more in a single box. With Google Wave you'll communicate with other people online just like email but you'll not have to have local copy like email. In the wave email you can easily get instant messaging option. While you'll  send mail (FYI, mail is not the actual term in Google Wave) to someone with Google Wave, if the user is online, then you can start instant messaging and the messages will be included in the mail. The wave server will maintain all the history of the email (including the instant messaging) and you can easily navigate through the history. Though Wave also has a lot more feature my main focus here was how Wave is going to shape the world of email.

 

I'll try to write an article on this later. you can follow the link http://wave.google.com for more details.

Thursday, September 24, 2009

Microsoft Ajax CDN

Microsoft recently announced that they are going provide Content Delivery Network support for ajax and Jquery. This is great idea as developers can link the jquery to Microsoft site rather than including in the project. There are few benefits of this:

1. Don’t need to maintain duplicate jquery or ajax files in the project. Just add a reference to an URL to Microsoft provided URL.

2. Surely page loading will be faster as the script is loading from different domain. Browser as usually doesn’t allow to load multiple resources from server while loading js file. So browser can request for two or more image files from a server simultaneously. But can request for single js file to per server and while loading js file browser stop requesting any other file to the same server. Now as the js file is deployed on different server so page loading will be definitely faster.

3. Currently for multiple sites you are deploying the common JavaScript file (say jqeury file) multiple times. So for site 1 the url of the jquery file is http://www.site1.com/js/jqeury-1.2.3.js. For site 2, the same jquery file is deployed as http://www.site2.com/js/jqeury-1.2.3.js. So browser is loading the same version of query file for different site. Now if you add CDN reference then the same jquery will be used for multiple sites. And as browser caches js file so once the js file is cached for site 1, for site2 the js file will not be download.

We can expect such type CDN network for other common components. Details can be found here on asp.net site.

Friday, August 28, 2009

Stemming in Search

Stemming is a process of reducing a word by removing some pattern. For example 'Search', 'Searches' and 'Searching' has the same origin and if user search with any of the words then content with 'search' keyword should be included in the result. So when user search with keyword 'Searching' how will you ensure that any content with keyword 'search' is included in the result? You can do so by applying stemming to the user search text. So if user searches with 'Searching' then the stemming process will remove the 'ing' from 'searching' and you will get the 'search'. Then you can use this keyword 'search' to use for searching content in your system.

The process of applying Stemming is shown in the following diagram:

 

image

So we can use a stemming library to parse the user search text and then we can get the root of each word user provided. Then we can search with stemming keywords. This will increase the chance of getting result from user perspective. You can get the open source stemming library from the following link:

http://tartarus.org/~martin/PorterStemmer/

Saturday, August 1, 2009

XSLT Debugging

XSLT is a great way of transforming XML document. But most of the developers who works with XSLT doesn't know that XSLT can be debugged in Visual Studio. Debugger in Visual Studio supports breakpoint, viewing XSLT executing steps, variable watching capability etc. There are two ways to debug XSLT in visual studio.

First Approcah

In this approach you don't need to write any code. You need your XSLT and XML file ready.

1. Open you XSLT file in Visual Studio.

2. On the properties of the XSLT file you will find Input property. Select the XML file you want to debug with this XSLT.

3. Start Debug

 

 

Second Approach

In this approach you need to write few lines of code to debug XSLT. For XSLT debugging from code you need to use the XslCompiledTransform Class.  The following code block use XslCompiledTransform to debug the XSLT. You can pass boolean value to XslCompiledTransform constructor to debug or not. The code section below is self explanatory and has proper comment to understand. You have need to have two files, source (XML) and styelsheet (XSLT). Then you need to specify the output file name which the XML after  applying stylesheet to XML. In the code section below I have created the full path name by appending current application directory with "Xmls/filename".

string sourceFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Xmls/XMLFile.xml");

        string stylesheet = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Xmls/XSLTFile.xslt");

        string outputFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Xmls/output.xml");

       // Enable XSLT debugging.

      XslCompiledTransform xslt = new XslCompiledTransform(true);

 

      // Compile the style sheet.

      xslt.Load(stylesheet);

 

      // Execute the XSLT transform.

      FileStream outputStream = new FileStream(outputFile, FileMode.Append);

      xslt.Transform(sourceFile, null, outputStream);

Now to debug all you need to do to put breakpoint at the line where transform takes place (xslt.Transform.....). when the breakpoint hits and if you press F11 then you will stepped into XSLT debugging.

 

Few more Information

While in debug you can get the current node by putting "self::node()" in the immediate window or watch window. You can also get the particular node value by writing any XPath  query like "./FirstName/text()". Here you will get the First Name with respect to current node. The text() is a function which returns the node's text value.