Archive for the ‘.Net Development’ Category

jQuery On the Rise

September 29, 2008

Wow. Microsoft will bundle the jQuery library with all ASP.NET MVC projects, enhance its interaction with Visual Studio through IntelliSense, use it in future ASP.NET Ajax controls, and provide support for the library itself. This is huge because most of the Microsoft universe doesn’t take note of anything not provided by Microsoft in a standard distribution.

Advertisements

A Hard Decision

September 27, 2008

I’ve been a consumer of the Facebook.NET framework for a few months now as I’ve developed several Facebook applications in ASP.NET. I chose that framework instead of the official Microsoft one because it seemed more logical and straightforward.

Honestly, I’m not at all certain why I originally chose one over the other. I read all of the blog commentary about each, I looked over the source, and I checked out the sample applications included. Facebook.NET struck me as elegantly designed, well conceived, and actively developed. Sure, Microsoft had commissioned and paid for the development and maintenance of the Facebook Developer Toolkit, which meant it was more likely to be around in the future. This possible objection was easily dismissed since Facebook.NET was open source and could be extended privately as long as need be.

What I couldn’t have foreseen were sweeping changes by Facebook to the underlying API within six months and a complete abandonment of the open-source project by its sole maintainer. Facebook has made a lot of mistakes in handling the transition but there’s precious little that I, as a third-party application developer, can do about that. So my sole responsibility is to keep up with updates to the framework and alter my code to accommodate the new (or changed) functionality.

Faced with a framework that isn’t getting updates, the responsibility expands considerably. One must either abandon the abandoned framework to search for greener pastures or one must take up the mantle of leadership by forking the project. Neither is a path to be chosen lightly for each entails considerable pain.

The choice was made easier for me by the fact that the Facebook Developer Toolkit was just as inactive at the time. I tried corresponding with the Facebook.NET maintainer and even succeeded a couple times: I would much rather have been a developer on a project than the man responsible. In the end, it became clear that the maintainer had moved on to other projects and that I was going to have to fork.

The result is fb.net. I largely brought it up to parity with the API changes in a span of two days but then I got distracted by work, family, and other projects myself. As it stands, there’s just a little more to go and then I can make a release candidate.

My only hope is that I can get this framework ready for a full release and then start looking to build a community that can assist in its maintenance. The Facebook.NET maintainer got it off to a good start; now it’s my turn to finish the job.

That’s Another Way to Go About It

September 12, 2008

I generally don’t like to showcase other’s inelegant code, but this couldn’t be more timely given yesterday’s Twitter created_at parsing tip. There’s always more than one way to do something, I guess.


       private static DateTime ParseDateString(string DateString)
{
Regex re = new Regex(@"(?<DayName>[^ ]+) (?<MonthName>[^ ]+) (?<Day>[^ ]{1,2}) ↵
(?<Hour>[0-9]{1,2}): (?<Minute>[0-9]{1,2}): (?<Second>[0-9]{1,2}) ↵
(?<TimeZone>[+-][0-9]{4}) (?<Year>[0-9]{4})");
Match CreatedAt = re.Match(DateString);
DateTime parsedDate = DateTime.Parse(
string.Format(
"{0} {1} {2} {3}:{4}:{5}",
CreatedAt.Groups["MonthName"].Value,
CreatedAt.Groups["Day"].Value,
CreatedAt.Groups["Year"].Value,
CreatedAt.Groups["Hour"].Value,
CreatedAt.Groups["Minute"].Value,
CreatedAt.Groups["Second"].Value));

return parsedDate;
}

For me, the lesson here is to know your libraries and always assume that someone else has done it better than you already. It then becomes a quest to find that better solution to the problem.

How to Parse DateTimes from the Twitter API

September 11, 2008

If you were wanting to interact with the Twitter API under .NET, you might find yourself trying to convert a date value from the XML results over to a DateTime in your code. Twitter uses a weird format for their dates—Thu Sep 04 11:09:28 +0000 2008—that doesn’t get converted properly with just a good ol’ DateTime.Parse. You could spend a lot of time iteratively trying to figure out the correct format to use. Or, you could just use the following (my free gift to you, dear Twitter-API-consuming reader):


DateTime.ParseExact((directMessage.SelectSingleNode("//created_at").InnerText), "ddd MMM dd HH:mm:ss zzzz yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);

directMessage here is an XmlNode representing a single direct message extracted from a list of direct messages. I found this out after many iterations since all of the .NET libraries for Twitter just punt on this conversion.

Microsoft Distributed Cache Services née Velocity

June 8, 2008

Microsoft has unveiled its new project code-named Velocity {via}, which is a .NET version of memcached for the Microsoft orbit. It’s not at this point baked into the OS or IIS, but it’s a start.

It’s got some additional features that go beyond memcached. One of the great things about memcached is its simplicity and limited feature set. It doesn’t worry about security and it’s essentially a glorified hashtable. For example, it offers named cache stores, regions within those caches, object searching, and different concurrency models. I can envision a lot that such functionality would get me if I were to replace memcached with it.

But I’m most curious as to the future of this project and its official position. If it’s going to become a supported technology and/or officially bundled, then I’d be willing to invest the effort in switching. But if it’s a one-off and never gets much attention, then I’d rather stick with the power horse that is memcached. There’s plenty of hope listed in their future feature list. I’m subscribed to the blog and I will be following this project closely.

Memcached Developments

April 24, 2008

Today I discovered that there’s a new port of memcached for Windows! This one reflects memcached v1.2.4, which added a bunch of new features like multi-get, append/prepend, and check and set. This is a huge release even though it’s in beta and is the first pass from the new maintainer. I am especially happy because I was considering putting in some time to do the port myself; I wasn’t looking forward to it since I’d have to learn C++ and it’d take me awhile.

I also found the BeIT memcached client library, which purports to improve on Enyim. I haven’t had a chance to try it out yet, but I like the embeddable, lightweight nature of its code. It supports a few commands that Enyim doesn’t so I’m going to give it a try. Enyim had a couple quirks that we found and worked around so I’m always willing to find a more straightforward framework if possible. I don’t understand the hashing issues enough to ascertain which is using the better-performing or more consistent algorithm so I don’t have a preference on that front.

All in all, these were two very welcome developments. It’s never been a better time to be a memcached fan in the .NET world!

Talking ‘Bout My Integration

April 9, 2008

I deployed my most recent project at work today. It’s a Facebook application that allows Quick Blogcast customers to link their accounts to their Facebook profiles.

I know that bringing a blog into your Facebook profile is nothing new. There are many such applications out there right now that can do that. But I think this Quick Blogcast version is unique in that you can make it so that your friends and visitors never leave Facebook, even to comment! What’s more, we leverage nearly all of the Facebook integration points. This allows the Quick Blogcast customer to publicize his or her blog to the fullest extent while still respecting the conventions and norms of the Facebook world. While that may not sound like much, it’s been quite a learning experience for me.

For one thing, I had to master the Facebook API. Luckily, I only had to learn it secondhand because I had an excellent framework called Facebook.NET to lean on. After a month or so of experience, I even felt conversant enough to help others and supply patches. In so doing, I apparently really helped the developer of Thugz Passion, a game which I’ve grown to enjoy.

It was also a chance to get to know memcached better. I used the terrific Enyim.com Memcached framework to interact with a Win32 port of the service. I wish I knew enough C++ to move that project to the current version of the Linux original. I futilely check the danga email archives to see whether anyone’s gotten impatient with progress and just did it on their own.

I was (and am) very impressed by memcached, which is an excellent (and free) distributed caching system. ASP.NET is top-notch at scaling but its caching mechanisms (namely, the object bags like Cache, Application, and Session) can easily become bottlenecks after enough usage is thrown at them. I think memcached offers a way out—it’s certainly worked wonders in the Linux world.

I affectionately call this integration app Quick FaceBlogBookCast. It cracks me up every time; it’s easily the most cumbersome portmanteau I’ve come across. (I can’t believe I forgot the other Facebook app I released today: Domain Center for Facebook! It’s a way to spontaneously generate domain name suggestions from the information contained on your Facebook profile. The algorithms right now are pretty coarse, but I plan to refine them each and every release until they’re uncannily right some day.)

[The views expressed on this website/weblog are mine alone and do not necessarily reflect the views of Go Daddy Software, Inc.]

ReSharper *IS* All That

April 4, 2008

Longtime readers may already know that I am a big fan of JetBrains’ ReSharper add-in for Visual Studio. I recommend it highly to any .NET developer, but especially to any of those who are interested in being more productive. You’d think that that’d be everyone, but I’ve found it not to be the case. Many developers I recommend the tool do don’t want to learn a new tool, aren’t particularly keyboard-enthusiastic, or mistakenly believe that ReSharper is superfluous. On that last point, I’ve stumbled upon a nice comparison chart showing that that is not the case.

There’s overlap, to be sure, but in nearly every instance I’ve encountered ReSharper’s implementation is more thorough and more thoughtful. It’s worth every penny.

Web.config and Virtual Directories

February 21, 2008

At work today, I ran into some trouble trying to set up a virtual directory as an application in IIS. My two applications, the parent and the child, occupied different locations in the filesystem, had separate app pools, and different app names. Due to the inheritance of Web.config, though, the HTTP modules defined in the parent app were throwing configuration exceptions in the child app even though the child app never referenced any of the HTTP modules.

I thought about adding an httpModule section to the child app’s Web.config with a remove call, but that seemed klunky to me. Frantic Google searching wasn’t giving any better solutions. Following the link chains from blog entry to blog entry to comments to more blog entries, I stumbled upon the answer:

<location inheritinchildapplications="false">
  <system.web>
   <httpmodules>
    …
   </httpmodules>
  </system.web>
</location>
source

Of course! This breaks the inheritance chain and it only touches the parent app’s Web.config.

The Things I Do For Money

February 21, 2008

Pardon me while I vent for a few minutes. I’m doing some contract development work for a non-profit—cleared long ago through my company’s legal team to make sure that I wasn’t running afoul of my non-compete clause—and to say that the conditions are sub-par is to put it mildly.

First, they’ve got a custom CMS that they’ve licensed from a local design house but they don’t have rights to the source code. So it took me forever to set everything up because I’d keep hitting little errors that stymied me because I couldn’t go code spelunking. But I persevered (barely) and now I’ve got a local instance of the CMS running. (The custom CMS, it must be said, is overly complex and often inscrutable. Even the design house’s lead developer had trouble explaining how it worked.)

The only way for me to develop what they need is to inject custom user controls into the page lifecycle. That’s no big deal, just an annoyance. But if I want to see how something looks, I have to copy my DLL from one directory to another each and every time.

Second, the CMS is written and hosted in .NET 1.1. That means Visual Studio 2003 (retch) and trying to remember what subset of C# isn’t available. A task which would be much simpler if I had a copy of my trusty ReSharper, which I don’t. $149 is a lot of money to spend but I’m getting close to throwing in the towel and ponying it up. (I would never even think of pirating it.)

The final abomination is that the database is hosted on SQL Server 2000 and that means Enterprise Manager/Query Analyzer. SQL Server Management Studio, part of SQL Server 2005, is so much nicer than that combo. Every time I fire up this suite of blast-from-the-past apps, I feel so dirty and ghetto. I’m hoping that someday soon they’ll have the budget to allow me to convert over to an open-source CMS built in .NET 2.0.

The relationship with the non-profit and my belief in the rightness of its mission is what keeps me going on this when every fiber of my being says, “Go elsewhere, youngish man!” They got screwed with this custom CMS—the peril of being non-technical—and I wonder how the design firm sleeps at night seeing some of the atrocities I’ve come across. (If I ever feel spunky or get to migrate away from their CMS, I’ll have some excellent horror stories to share. I should probably write them down somewhere for that eventuality.)