Categories
Software Development Technology

ASP.NET Embedded Database Support

Now this is cool, Microsoft has added embedded database support to ASP.NET 4 allowing you to create web applications with ASP.NET & SQL Server CE 4. Scott Guthrie (@ScottGu) explores this in more detail:

http://weblogs.asp.net/scottgu/archive/2010/06/30/new-embedded-database-support-with-asp-net.aspx

My Thoughts? This is a fantastic feature for those of us who are inclined to write occasional small personal web apps; we are spared the development overhead of having to develop a full-fledged SQL DB. Now all of you still using MS Access on your web apps, get with the program! One concern I do want to see more information to assuage is concurrency - obviously this solution would be fit for apps that have more than a couple of users but ScottGu's post doesn't mention much about this. Feel free to share your thoughts in the comments!

Categories
Software Development Technology

.toUpperCase() vs. .toLowerCase()

I don't remember where I got the notion, but for quite some time I have been under the impression that JavaScript's string.toUpperCase() method was always faster than string.toLowerCase(). It occurred to me today that I was taking this on the word of some anonymous blogger somewhere so I decided to put my long held belief to the test and was quite surprised by the results.

***UPDATE - 4/28/2010***

Google released an update to Chrome today (...). One of issues fixed was 42158: Decreased JavaScript benchmark speed. So I reran the tests & have included it in the results table.

In summary across multiple browsers, string.toUpperCase() was never faster and the results varied drastically:

All results are in milliseconds (ms).

Rank Browser .toUpperCase() .toLowerCase()
1 Opera v10.51 (Build 3315) 2.835 1.337
2 Safari v4.0.5 (531.22.7) 4.024 1.832
3 Internet Explorer 8 v8.0.7600.16385 3.306 3.130
4 Firefox v3.6.3 5.961 2.848
5 Chrome v4.1.249.1045 (42898) 9.618 8.159
6 Chrome v4.1.249.1059 (44723) 28.364 24.644
7 Chrome v4.1.249.1064 10.16 7.897

The really surprising results are the first one and the last one: Opera blew all of the other browsers away, it's nearest competitor, Safari took 41% longer with .toUpperCase() and 37% longer with .toLowerCase()! The real surprise came from Chrome; Google touts Chrome as one of the fastest JavaScript engines available (with which I generally agree). However, they clearly have some work to do on their string functions. In fact, while I was testing, I noticed that a new version of Chrome was available (4.1.249.1059) and installed it; as you can tell from the results, the performance of both functions decreased by a factor of 3!

Another look at the results:

 

The test consisted of converting a string of 709,180 characters of generated Lorem Ipsum text toUpperCase()/toLowerCase() 1,000 times and averaging the results. The test is available below; feel free to comment with your results and any recommendations for improv

ing the tests

JavaScriptStringTests.zip (199.63 kb)

Categories
Software Development Technology

Configuring JavaScript & jQuery Intellisense & Debugging in Visual Studio 2008

Let me begin by saying this post is in no way a knock against Firebug; Firebug is a fantastic tool that I do use on occasion. It is, however, my preference to develop within a single, unified IDE; Visual Studio 2008 was a huge leap toward this objective (I'm installing Visual Studio 2010 as we speak - I hold great hope for it to be another giant step forward).

Step 1: install Visual Studio 2008 SP1 if it's not already installed.

Step 2: Make sure that script debugging is not disabled in Internet Explorer (yes, IE is necessary for our purposes).

  • Tools > Internet Options > Advanced > Browsing - Disable Script Debugging (Internet Explorer): Unchecked

 

Categories
Software Development Technology

Code Samples to accompany my presentation at the OKCDG

Here are the code samples from my presentation to the Oklahoma City Developer's Group on April 5, 2010 (the slide deck is below in a previous post). I broke the examples out into their own pages to make it easier to browse. Let me know in the comments if anything doesn't work or isn't working as you would expect.

SynchronizingAJAXandASPNET.zip (94.62 kb)

Categories
Software Development Technology

AntiXSS Library

During the dinner presentation to Oklahoma City Developer's Group this past Monday (4/5/2010), the topic of input validation was brought up and I recommended the Microsoft AntiXss library to assist with this task. As it turns out, there seems to be an even tighter way to integrate this library into your projects:

http://haacked.com/archive/2010/04/06/using-antixss-as-the-default-encoder-for-asp-net.aspx

Haacked.com presents a great way to integrate the AntiXss library as the default encoder for ASP.NET 4 automatic code block encoding; definitely worth checking out.

Categories
Software Development Technology

Synchronizing AJAX and ASP.NET (OKCDG Presentation)

This is a follow-up to my presentation at the Oklahoma City Developer's Group meetings. I really enjoyed giving this talk and really appreciate the opportunity! I received a lot of great feedback and look forward to any other comments anybody has (feel free to add your 2¢ in the comments below).

 As promised I've attached my slide deck to this post and I will have my code samples up asap so stay tuned for those.

Synchronizing AJAX and ASP.NET.zip (132.48 kb)

Categories
Software Development Technology

jQueryUI vs. Visual Studio jQuery IntelliSense Pt. 2

I thought I would elaborate

on my previous post on the jQueryUI breaking the Visual Studio 2008 Intellisense -vsdoc.js file. This is a quick overview of the two changes necessary to correct the problem. The file breaks in two locations line 165 & line 5815 (Visual Studio indicates these errors as being on lies 164 & 5814). Two quick changes:

Line 165 from this:

selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;

to this:

try {
    selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
}
catch (ex) {
}

And line 5815 from this:

elem = jQuery.makeArray( div.childNodes );

to this:

elem = jQuery.makeArray( div.childNodes );
try {
    elem = jQuery.makeArray( div.childNodes );
}
catch (ex) {
}

That should take care of the issue.

One further note, the jquery-1.4.1-vsdoc.js file will work with the updated jQuery 1.4.2 library, just change the file name to jquery-1.4.2-vsdoc.js.

 

Categories
Software Development Technology

jQueryUI vs. Visual Studio jQuery IntelliSense

I stumbled upon an issue with jQuery IntelliSense in Visual Studio 2008. Basically, the jQuery library (i.e. jquery-1.4.2.min.js) & it's Visual Studio IntelliSense document (i.e. jquery-1.4.2.min-vsdoc.js) play nicely, but when a reference to the jQueryUI library (e.g. jquery-ui-1.8.custom.min.js) is added, the whole thing becomes hung-chowed. To make a long story short, I've made a couple of modifications to the Visual Studio Intellisense document & everyone on the playground is happy again. The updated file is available below:

jquery-1.4.2.min-vsdoc.js (229.42 kb)

If this helped you or if you have any suggestions for improvements, let me know in the comments!

Categories
Software Development Technology

The Simple Solution to List.Find()

Today at work, it was necessary to code a solution that included a List.Find() that I've coded many times and has become almost second nature . . . in C#. However, the app, being written in VB, required a solution in VB. After some searching on the web, I was left without a satisfactory solution. After several (read: many) rounds of trial and error, I finally stumbled upon the correct syntax. Later this afternoon it occurred to me that this would make an excellent inaugural blog post.

In C#, the code is very simple (examples can be found on MSDN). Assuming we have an object named Person that has a property named FirstName of type string:

string strPersonToFind = "Justin";
Person myPerson = People.Find(
    delegate (Person p)
    {
        return p.FirstName == strPersonToFind;
    });

In VB, the examples were far less clean:

Dim strPersonToFind As string = "Justin"
Sub doSomething(ByVal People As List(Of Person))
    Person myPerson = People.Find(addressof FindPerson)
End Sub
Function FindPerson(ByVal s As string) As Boolean
    If s = strPersonToFind Then
        Return True
    Else
        Return False
    End If
End Function

Seriously? The VB example has several obvious shortcomings. First, it requires a page-scoped variable for comparison or a hard-coded comparator. Second, it took 11 lines of code to accomplish what was done in C# in 3. Third, it's just plain ugly; it requires jumping between Subs & Functions and is pretty hard to follow and maintain.

The solution is very simple, looks similar to the C# example, and can be used from within a single Sub or Function (eliminating the need for page-scoped variables):

Dim strPersonToFind As string = "Justin"
Person myPerson = People.Find(Function(ByVal p As Person) p.FirstName = strPersonToFind)

Only two lines of code and very clear and concise syntax.

Important Notes: This is in reference to System.Collections.Generic.List<T> (C#) and System.Collections.Generic.List(Of T) (VB). Also, I believe this known as Lambda Expression syntax and as such, only works .NET 3.5 and higher.

If this helped you, let me know in the comments!