Friday, September 12, 2008

Migrating from ASP to ASP.NET

My Team and I have been migrating an ASP page over to ASP.NET for around 2 weeks now.  The site we are moving is very large and will require us to keep most of the ASP pages intact and slowly move them all over in an Agile approach.  The pages the client wanted us to leave in ASP were mainly the Banner or Header page, and the Left Navigation page of pages that would be with or should I say embedded into our ASP.NET pages.  So we had to embed those pages into our Master Page.  The standard #import from ASP did the job however we started noticing that in IE our buttons were not triggering a postback, yet in FireFox it was working.  Wow!!, all this time we were running FireFox and all was well, now we were struggling with a common browser that is not working.  I spent 2 days testing and analyzing, keep in mind we did not have access to the code of the Banner file.  We finally got access and discovered that the Banner section was importing a Search page of which had a Form on the page.  Voala, we figured it out.  You cannot nest forms in ASP.NET.  So in IE the Postback was completely ignored.  However in FireFox we knew nothing of a problem.  Just another one of those events that can make your head turn.

Sunday, April 13, 2008

Our dog Skateboards

The kids and I went outside so they could ride the skateboard.  Our dog happened to be watching and decided to skate on her own.  Here she is:

Thursday, February 21, 2008

Relocating back to Texas

This weekend my family and I will be relocating to Texas.  Los Angeles has been quite the experience and I sure will miss it here.  If only a home were affordable we would stay.  I'm off to experience the world of contracting with the State of Texas writing tablet applications.  I'm a bit nervous about contracting but at the same time a little excited.  It's something new and will be full of new learning experiences.  I will try to get more articles up in the near future, I have been a bit lazy about writing them and want to get more content up.  Well as Willie Nelson would say, "On the Road Again".

Friday, February 15, 2008

Field or Property?

A coworker asked me a simple question that I really just didn't know. What is faster, a field or a property? I know a property has the get and set, but I thought since the property was pointing to a field that it would be equally comparable. So being geeks we put the question to the test. Created a simple console application with a field "A" and a property "B" and bench marked 100 repetitions.

static string A = "";

static string _B = "";
property static string B
get {return _B;}
set {_B = value;}

Then within the main method we create a StopWatch from System.Diagnostics and ran the following loops:

StopWatch stopWatch = new StopWatch();

for(int j=0; j<100; j++) A=A;
Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Field A took {0} mil.", stopWatch.ElapsedTime.TotalMilliseconds);

for (int i=0; i<100; i++) B=B;
Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Property B took {0} mil.", stopWatch.ElapsedTime.TotalMilliseconds);

Field A took 0.0025 mil.
Property B took 0.4457 mil.

The biggest shocker to me was that a field is 99% faster than the property. Now I know there is the getter and setter but I had no idea it had that much of an impact over a field. I hope that after someone reads this their not going to go out and change their code from using properties to using fields. The point of this entry was not to remove properties but to understand the question at hand. Remember private fields do not serialize to xml if your class is marked as serializable so don't run out and change anything. A few milliseconds difference is not enough to make me go out and change an application unless its an intense gaming app in which case we want the fastest processing possible. Properties are awesome and we all should be using them. This test was a great experiment in knowing that if a property is only being used to store a value and your class is not serializable then it doesn't hurt to use a field instead of the property for a very small unrecognized performance gain. But all in all I still love properties and intend to continue using them.

Creative Commons License
Blogged Information and Code is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.