Thursday, April 30, 2009

How to add a control to the header of a UltraWebGrid Infragistics control

I found this link:

http://devquirks.com/SelectAllGridColumn.php

But note that the click event does not get fired on the server.

Office 2007 horribly slow?

Because of the search integration within it, I know for a fact that
office 2007 makes your PC very slow. I also know that when you have
many emails in your personal folders, outlook 2007 is the slowest app
on the planet.

Announcing a solution! - day before yesterday Microsoft released a
slew of updates including office 2007 SP2, SQL server 2008 sp1,
sharepoint sp2, etc.

This resolves all performance issues with all these software. The
major improvements are in the performance of office 2007, IE 8 &
sharepoint.

Sharepoint was a crawler till now. It became a corvette after the
update.

Wednesday, April 29, 2009

One feature no .NET OR/M tool provides

Here's an interesting tidbit. There is one thing my OR/M tool can do which no other OR/M tool in the world can do - mine is the only one which lets you create entity, criteria and interface classes for a complex stored procedure which contains insert statements, temp tables, etc but still returns a resultset.

Every other OR/M tool analyzes the stored proc and says it is an action stored proc. I don't analyze the stored procs automatically, I let the user enter the parameters, run the query and then depending on the resultset, I generate the criteria, entity and interface classes.

So, it beats LLBLGenPro, LINQ to SQL and Entity Framework. None of them support these stored proecedures!!!

It is a shame guys!!

Response to: Stored Procedures Vs Dynamic Queries

 
I have a difference of opinion here, because I have also built an ORM mapper/ code generator before. My opinion is that, the whole area of dynamic queries being faster and better than stored procedures only makes sense in the context of having stored procedures for specific tables. Which means, when we have a tool which directly operates against tables then it makes sense to have stored procedures vs dynamic queries, and there dynamic queries can be recommended because we are only talking in the context of a single table.
 
So a C# developer can write the query in C# and have a better dynamic query than the code calling a generic stored procedure because it is generic.
 
However, in big, real world applications, nobody works in the context of a single table all the time. Mostly, what we retrieve spans multiple tables and complex queries. What we insert may also span multiple tables. So, it becomes more difficult for a C# developer to write a complex query like that in C# and still have it as optimized.
 
Because of this, in such situations, stored procedures will actually work better, faster, and have lesser chances of error because it is written by a database guy, and it is easier to write complex queries in SQL (notwithstanding the newer advancements in LINQ).
 
So, I think every ORM tool must fully support stored procedure code generation, and stored procedures are fully valid in these cases.

Monday, April 27, 2009

How to handle multiple windows with different states in a web application

I know a lot of people have written a lot of ways in which to do it. But, I have a way which I think works when you actually consider that a new window is a "GET" on the server. Most of the implementations floating around are for "POST". The really difficult problem to crack is that, there is no way for the server to know whether the "GET" which is being processed is a page refresh request OR a File >> New Window Request. There are two ways of doing this, depending upon which kind of application you are:

The Easy Way

The easy way is only possible when your application opens in a full window mode (business application), and you do not show anything like the address bar (even if it is shown, this has to be read only), and you do not show any browser buttons OR right clicks.

This is simple:

1. Every time a window is opened, have a window identifier in the query string.
2. Use this identifier on the server as a part of the key while storing anything in any shared storage for the user (like session or cache).
3. This ensures that for different windows, the server stores the information with different keys.

This works very, very well. Users like to use the cool "New Window" icon to open a new window. 

The Difficult Way

I went through a struggle to get this going because, in a regular browser application, the user can hit the browser buttons and also, change the query string. So, there is no apparent way to handle all these events and ensure that we get a unique window key when the user presses, Page >> New Window, because there is no way to detect whether the user did that from the client.

This is how I finally did it:

1. Used a base class to do all the processing.
2. Uses logic similar to method 1 (first section) for window identifiers.
3. What I did was ensure that before every user request from the client, an AJAX call is made to the server to update a variable.
4. It is possible to detect page refreshes done by the user through any mechanism using the below:

        window.onbeforeunload = function()
    {
        if((window.event.clientX<0) || (window.event.clientY<0))
        {
            HandlePageRefreshButtonClick(); >> Make Ajax call inside this function, and then in callback event.ReturnValue = true so that refresh will happen
        }
        else 
        {
            HandleRightClickPageRefreshClick();
        }
    }

5. So, page refresh is covered, for any actions from your page, you can do the AJAX call to update the server FLAG before doing the actual GET request.
6. Any request which goes to the server which does not have the FLAG set will thus be the "NEW WINDOW OPEN" request. This can be handled, and you can redirect the user to the same url but with a new window identifier.
7. Clear the FLAG at the end of every page load, so that it is set only before a new request comes from the server.
8. This means, before you redirect also, you need to set the FLAG in the session. An easy way is to handle all redirect methods through a static method in your class rather than the ASP.NET Response object.
9. Ensure that all links in all pages call a JS method, and this method makes the AJAX call before you open a new window or go to another page. This can again be abstracted into a generic JS class.
10. On the server, to see whether you need to redirect with a new window identifier:
         a. Ignore for login page.
         b. Ignore is page is posted back.
         c. If FLAG is null, user did not request the window explicitly - so handle this case.

11. If a user modifies the window key manually, then handle that case by again generating a new window identifier on the server and redirecting to the same page with the new identifier.
12. You can handle Ctrl + N also, and ensure before page refresh to make AJAX call.
13. Remember to use ALL session variables WITH the window identifier as the key, otherwise, the session will leak to the other windows open.
14. If you encrypt the query string, remember you will not find it easy to send new values through query strings anymore. Remember to allow for url decode and encode after encryption and before decryption.
15. Even the script manager used to have the web service reference on every page can be injected into every page from the base page

The method is kind of complex, but it does work for 2 GETs. I have tested thoroughly.

Saturday, April 25, 2009

Why Modern Education might lead to the demise of civilization

I was thinking about the way in which modern education is taught in schools today. And I realize that the way in which we ram down theorems and rules actually harms the ability of children to innovate. The problem is that instead of discovering how stuff is done, they are taught in an hour what might have taken someone years to find out in an earlier age.

What is the problem with this?
- There is so much indoctrination that we get trapped within the boundaries of what we have been taught or what we have read. How can we think out of the box, when our mental model itself is made of the box?

I mean that, if a person has not done a PHD, he might be able to find out a better solution than a PHD simply because he is not thinking confined to the boundaries of what he has learnt. He may be wrong most of the time, but there is a 1% chance he might come up with the next theory of relativity.

Maybe Einstein was not intelligent – he was very poor in school, maybe he learned so less that, in the process of thinking based on his own thought model, he was able to come up with something different. Maybe no-one else has come up with something as big as the theory of relativity because they have learned too much?

I have seen toppers in class unable to think straight when confronted with a problem – because they are very good at learning what someone else had figured out, but never learned how to figure out something on their own. So, I say, the more we learn, the more we bind ourselves in mental shackles.

Why has India never come up with an Einstein or a Thomas Alva Edison?
Because there is too much indoctrination, too much mugging up, too much stuffing the brain with stuff other people struggled to understand over the years and came up with thinking from scratch.

We tend to forget that education, like software should be tailored to the human brain, and not the other way around.

If a student fails in class, maybe it is not the failure of the student. Maybe it is the failure of the education system which is not able to get through to the most advanced computer ever designed – the human brain.

Maybe the student who fails is the best suited to come up with the brilliant innovation 10 years later, and the topper is destined to be struggling trying to resolve a problem nobody wants to solve. An interesting way to look at it is that, when a software crashes a computer, we do not blame the computer – we blame the software. If education is “software”, and the computer is the very different, unique, special human brain – why is the brain said to have failed?

If we understand this, maybe we won’t collapse like the older civilizations have in the past...

Thursday, April 23, 2009

The problem with Microsoft

Somewhere down the way, Microsoft lost its soul. I now see it as a “has been” company where they copy whatever is cool out there and then announce new projects which they drop like hot balls after sometime. It is really pathetic what they have become. The only thing I like about Microsoft Software is their Visual Studio suite, but as everyone knows even though coding is easier, the end product is not.

Windows applications are slow, and WPF is a farce. Even silver light which is based on it is pathetic. I really wish MS had spent the time developing Script# into a real platform than wasting time on WPF. It would have been lovely to finally have an object oriented way to write client script for browsers. I love the fact that script# compiled to JavaScript. It is a really awesome idea which has been ignored by Microsoft because of vested interests, rather than technology.

I say this time and again and I will re-iterate once more, the failure of Microsoft to develop a proper phone OS with so much time on their hands, and the way Apple came up with the iPhone OS, and how MS shamelessly tries to emulate it now, so many years later.

C’mon... Apple has to show every other lousy phone OS maker that it makes sense to have a phone where its firmware can be updated for new releases and patches. This is not high science – it is purely what happens when technologists run a company to make better software compared to a bunch of business people trying to figure out how to crawl their way around by spending less and utilizing existing resources rather than coming up with a better solution which fits the problem.

The solution should fit the problem and not the other way around.

Software was made for humans, and not the other way around.....

Tuesday, April 21, 2009

To add features or not?

It is very interesting for me when I look at it today - the way Apple
does new stuff versus the competition. Everyone else tries to stuff
too many features into too less and nothing works well.

I think Apple had the audacity to pare things down to the minimum and
the strength of character to determine which features mattered the
most in the beginning.

The interesting part however is that, by adding new features later in
the game, and often after the open source community, they gave the
users time to learn & understand the new stuff while giving themselves
time to do stuff properly & get a stable product in the bargain.

Why the mac netbook will be a hit

The Mac netbook will be a hit because OSX works 5X faster and more
stable than Windows on the same hardware. With the Air, Apple already
has some experience building a fast experience into a restricted
space. It goes without saying that the end user experience will be
great because of this.

Just take the iPhone as an example of one of the fastest hardware-
software combo's available as a phone. I have tried the rest, most of
it sucks bad.

Monday, April 20, 2009

So many companies closing shop...

It is a dismal time to be in America now. Especially, in silicon
valley, these companies are closing left and right. People are being
fired.

Friday, April 17, 2009

How to buy a good Mac

I have heard many people complaining of problems after buying a Mac, or anything from Apple for that matter. But, I have never had any issue with any Apple product except an iPod I brought a long time ago. I have managed to have a fault free experience so far because I always wait a year or more for the product to stabilize and for the prices to go down.

This has gone pretty well so far. I waited almost 2 years before buying my first iPhone - it never had any issues. Then, I got the second iPhone (3G) one year later - works perfectly. MY latest acquisition is a MacBook Air with the SSD hard disk. I got it for less than half the price and it works beautifully so far!!

So - whatever they tell you - it is better to wait for the problems in the product to get resolved.

Thursday, April 16, 2009

And the mac wins!

I found other areas where the Mac won hands down over a better
configured PC:

1. Better utilizes CPU and gives much better performance over similar
or higher configured PC's.

2. File transfer over a wifi network 10X faster than much, much faster
PC.

3. Video playback much faster, lesser crashes than much better
configured PC.

I am surprised that when you consider a program which can be installed
on a PC & a Mac, the Mac runs it better and faster even on lesser
hardware.

We a comparing a 2.4 GHz, 4GB RAM laptop with a 1.6 GHz, 2 GB RAM air.
I am wondering whether this is because the PC development tools are
too much backwards compatible that it is dragging it back.

You must have read my previous posts on www.todayamerican.com on how
Vista bests XP in some ways?

Well I think the very advantage of a PC - that it has more programs is
it's undoing, because definitely it has quantity, but not much quality
(in comparison).

I have tried out various Windows flavors on different hardware, the
only one I have liked is windows 2008 server. Vista is not adequately
performant even on very expensive machines ($4000+).

I think the next step for any long term windows user is a mac -
because of it's speed, performance & stability.

Tuesday, April 14, 2009

MSMQ a bad choice for enterprise applications

I have learnt the hard way - MSMQ is a really bad choice for an enterprise messaging solution. MQ Series is a better option.

Linq should not be used at this time for database access, if too is not production quality at this time.

WCF is fine now - after .net 3.5 sp1.

WPF sucks big time - wait for atleast one year before going ahead. If you don't believe me true the times reader app from nytimes.

I hate recruiters who want developers who are good in the front-end, middle tier & the database. They end up getting people who can do all 3, but not very good in any of them.

Sunday, April 12, 2009

Search across all your machines & Download files - seamlessly & securely

I would like to take a few minutes of your time today to introduce what I have been working on since March 2008. I call my site: www.sparrkle.com and it resolves one of the problems I have had for a long time.

Like any other geek, I have many computers at home and office, and there have been times when I know that something which I need is on one of these machines. Till today, there has been no way for a person to securely search across all her/ his machines and download files - from any of her/ his other computers.

So, I have built sparrkle.com which lets you download what is effectively one year of my life. It uses windows desktop search, sql server express and a variety of windows services on your machine to let you search all your computers. Once you see the search results - simply by clicking on the file name, you can download your file from any computer which has sparrkle installed on it. No need to worry about firewalls, complex configurations, nada - nothing. Just click to download.

It is completely seamless, and very, very performant. I have spent months testing it for stability, installation and performance. I hardly noticed it when I was using it from a $400 laptop from Walmart, with a 1.6GHz AMD processor.

It is very secure, your information is transmitted using encryption and if some machines are offline, when they come online sparrkle will automatically query those machines and retrieve the search results. By default, you don't have to open any incoming ports on your firewall.

Basically, all you really need is just the windows install and that is it! - You can register after installing the software. The only pre-requisite for sparrkle is windows desktop search on pre Vista machines.

If you are interested in this solution, I would really be thankful, if you atleast visit my site so that I can know how many people would like to see a software like this.

True love...

True love is a weird thing,
It never happens in a flash,
Or at the first glance

You spend years alone,
Loneliness becomes your best friend,
You see happy couples all around,
You wonder when you will find the one

She is definitely out there somewhere,
Maybe she is right beside you now,
She is the one who has always been by your side

Amazing!

The father of fiber optics is Narinder Singh Kapany, who is a punjabi
sikh!!

Without this man, there would be no Internet today...

Saturday, April 11, 2009

.Net Secrets

Don't use static methods for writing middle tier methods.

You will need to call the GC explicitly if you are writing a .Net 1.1
application.

If you use .net remoting, every class you want to truly run remotely
has to be included in the remoting client & server config files.

The biggest reason to migrate to .Net 3.5 is for using LINQ, but not
for database access.

As of this time silverlight or WPF is not robust enough for a
production application.

Windows 2008 Server does significantly improve your app speed.

Yahoo iPhone App - Nice!

I have to say that Yahoo has done a gr8 job in their app for the
iPhone. The NY Times app used to be the only other option, but once it
started crashing, it has been pretty much unusable.

I went through the crazy objective C language a few days back and feel
"no wonder!!". When are these guys going to make things better?

Apple should implement a higher level popular language like C# or Java
so that more developers can learn iPhone programming easily and build
stable applications.

The kind of features you find in Objective C maybe powerful &
flexible, but the syntax is like a crazy, mad beast!!

Friday, April 10, 2009

The Software Development Lifecycle

It is an interesting question to think about - which is better? - the complete adherence to processes or the complete lack of one. My opinion is that the answer lies somewhere in between and both extremities are not effective. Some people can do very well without any processes while others need step by step instructions on how to move forward.

Too much adherence to processes can only be done in companies with unlimited money & time to kill. Take the example of the recent case of a person leaving Google because of weeklong meetings on which of the 48 shades of blue to choose.

In startup companies on the other hand, because of the lack of time, people usually follow no processes leading to disaster. In today's world where there is a lack of time, it is essential to me able to come to market quickly otherwise you lose your advantage. See the case of Microsoft and Vista. It took more time & had a lousy reception even after it arrived.

Wednesday, April 8, 2009

How apple can beat microsoft

I think one way for Apple to quickly increase their user base would be
to sell OSX as software which can be installedon any PC. I can
virtually guarantee that most iPhone users with PC's will consider
buying it.

Also I see the OSX as being a very good replacement for the computer
connected to the TV in my living room.

It can give very good performance - this I have noticed since getting
my mac. Only problem is, now I think all laptops are obscenely heavy!!

Tuesday, April 7, 2009

There's a book which is Life. And a writer who's God.: White Weird Thoughts

http://nambradth.blogspot.com/2009/04/white-wierd-thoughts.html

I liked the above story.

Apple released new iTunes 8.1 Update!

I just found this out. Try running apple update on your windows/ mac. It improves performance supposedly.

By the by, I just installed office 2008 for mac. It is pretty interesting I would say!

Getting to know my new Mac

Nowadays I am getting to know my new mac better. I got office 2008 from macmall.com, but was pleasantly surprised to see that the mac could open word documents even without anything installed on it.

I like the default email client. I think it works on IMAP way better than any windows client including outlook express or even ms outlook itself. In fact it is my observation that ms office 2007 significantly slows down a computer.

I am not sure what the reason for this is. Why is the mac more performant than a better configured PC?

On the other hand, I do have some peeves like no right click button on the air (what were they thinking?) and the difficulty to get a window to go full screen (maybe there is an easier way than dragging the mouse).

Windows does not have anything like spaces & my biggest complaint with it is that it has not changed much since windows 95 in a fundamental manner. They should do something so that for different classes of users they can provide drastically different stuff.

Windows is boring...

Monday, April 6, 2009

Welcome to my blog!

I have permanently moved my blog here now. Mainly because it is easier to publish and quicker to post stuff here. This is the default blog for my website: www.todayamerican.com - be sure to take a look when you get the chance.

The latest news is that I have a new website now @ www.sparrkle.com - check out my application which connects with windows desktop search and lets you search all your machines from anywhere.

I was a pc, became a mac now. I got a really sweet deal from the apple store - the air is an awesome machine primarily because it is not slow and it is sooooo portable. When I went to Best Buy to try the laptops, I looked at many brands, but I loved the air even more than the gorgeous 15 inch macbook pro because it is really light and I love the edge of the air - which is so thin, my wrist does not hurt while typing. It helps too that the keyboard has a backlight, and speed is not an issue because I have the air with the 64GB SSD option.

I have been a PC for so long. What I like about the Mac is that it is simple, fast and does not have the loads of junk which comes on a windows machine. I just wish it were slightly cheaper so that more people could discover it. However, I do think the Mac is better for geeks than for common normal users because it is more technical than the PC. I wish Windows could come in such a version with everything pared down to the minimum.

Expect to see some iPhone apps soon.