Thinking way too long about the subtitle RSS 2.0
 Tuesday, February 17, 2009

I was crawling around the CodePlex site and discovered a cool utility:

"Google Book Downloader is small utility which allows you to save book as PDF from google to your local filesystem."

Google has made public domain books accessible online and this .Net app can make them accessible on a plane. What will they think of next?

Tuesday, February 17, 2009 9:30:52 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
books | fun
 Tuesday, January 27, 2009

When I've needed to invoke a cache mechanism for data on a web site, I've happily used the ASP.Net Cache object over the past few years. It's a nice model for storing a chunk of data under a key until a specific time or for a given duration, providing the application domain doesn't recycle.

I've even hooked up some systems that resemble a Rube Goldberg apparatus to get the same features as a job scheduler, but I don't like to talk about them. ASP.Net will fire an event that you can use when something expires from the cache and therefore give you the "Cache, Wait, Expire, Do Something, Repeat" model for solving a job scheduling problem.

.Net 2.0 and up supported the SqlCacheDependency class. One of its talents is the ability to expire a cached object when the underlying database changes. Before this feature was available, you might wire up specific cache expiration logic in relevant insert, update or delete functions of your app. However, that falls short when the database is updated outside of the trip wires you set in your own code. Another application might update that database, or someone might edit the database through Query Analyzer.

Way back in the day, my team set out to bag the big beast by writing a trigger in SQL Server that would reach out an edit a text file whenever a specific table was modified. This event would be observed by the cache dependency object that was good at watching physical files for changes and ska-doosh! We've got our SQL Server cache dependency working.

Nowadays, those long, verbose methods aren't required. We've got a set of fancy new tools, namely, the SqlCacheDependency object. Or so I thought.

Its great that support goes all the way back to SQL Server 7, albeit via a costly polling mechanism. SQL Server 2005 gave us a direct feedback loop that avoided the polling system. I've know about this feature, as a concept, since it came out but only in the past few weeks have I really looked at the code to use it and I'm honestly a little shocked at the site.

I was really expecting something akin to the familiar practice of checking the cache for the existence of the object, and if necessary, repopulation of the cache. It turns out there's a few more steps, and a little craziness if you want to use LINQ to access your database.

I'll always leave the door open and hope that some day I'll learn the super easy way of doing this, but today, so much of this is in the non-trivial bucket that I'm really tempted to leave it alone and continue my current caching practices.

A year or more ago, I would reach for the data access block inside the Enterprise Library as a default choice. It's a great data access layer and sure beats writing all that goo on my own. Today, I'll reach for LINQ as my default choice. As I understand it, Microsoft is touting the Entity Framework as the future of data access, but today, I'm still sitting contently in the LINQ boat. Who knows what the future holds for me.

To be fair, the example code in MSDN that shows how to implement the SqlCacheDependency actually looks pretty good when you're creating your own Command objects. Not much to talk about there. But I was disappointed when I looked at the LINQ story. Perhaps LINQ just got out ahead too far from the pack and better things are coming.

One of the cleaner approaches to caching LINQ data I've seen was on the MSDN Code Gallery web site. Here, the developer created a sweet extension method that creates the Command object on the fly, executes the query and caches it all inside a generic method. It bears a little more review on my part, but its neat enough that I thought I'd share it. Its less than 50 lines of actual code, but they comment the crap out of it.

The whole idea of having SQL Server notify ASP.Net involves more considerations than the simplistic approach that served me well for years. For example, I can have SQL Server watch a specific table, a set of tables, or a specific query (this last options requires SQL Server 2005 or better). In addition, you'll need to start and stop the entire process when the application domain comes up and gets recycled respectively. You probably with a few lines of code in Global.asax. Finally, you're going to need a few more elements inside your config file that describe a few more details of the cache behavior. All in all, I like the direction, but I'll be happier when/if the LINQ story improves.

Tuesday, January 27, 2009 6:57:42 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
asp.net | LINQ
 Sunday, August 10, 2008

I'm digging the http://www.nbcolympics.com site in Silverlight. I can see sports and interviews that I'm interested in and review close plays as much as I like. I've shown this to the wife and the extended family over the weekend.

One thing that really keeping this from being the best thing ever is the user experience. For example, the Control Room is a place where I can select up to four videos to watch at once; one large and three side videos. That's really cool. However, the extended family was the real test; and they were a little frustrated.

The sucky part of the Control Room is the search interface. Here, I'm given a tiny up/down arrow at the bottom of the thumbnail stack. This is something visitors will do many times, every time they visit the site to see the next six or previous six videos in the stack. Why not make this click experience really easy to hit with big, phat arrow overlay icons? Maybe even advertise key strokes that do this. Its just really frustrating for non-technical people to use.

There's too many obfuscated clicks like this in the app. Just a few slight UX improvements would have gone a long way here. NBC Silverlight team, I give you a straight B here. Good job on the insight to give us what we want (choice in viewing Olympic events), but a "meh" job in giving me to the tools to make that choice.

Sunday, August 10, 2008 10:00:47 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
events | Silverlight
 Saturday, August 09, 2008

There's a really cuil set of photos showing the Large Hadron Collider being setup in Europe. Very high tech stuff.

Just a little bit down from the top of the photo stack is an image of someone way down the aisle in the server room. You get the idea that there are just racks and racks and racks of servers with a mind for effective use of power consumption, space utilization, heat and all the other green elements.

The person at the end of the aisle is working on a server. They're sitting at a workstation, typing on a keyboard... looking at a monitor. Not a slick flat screen, but a huge honking cathode ray tube monitor from 1994! Hah! That thing probably takes up the space of three or four servers and gives off as much heat!

Saturday, August 09, 2008 9:32:43 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1] -
hardware | observations
 Thursday, July 31, 2008

I just had a Pwop moment (the sound of a forehead slap) with LINQ:

I needed to retrieve a distinct list of years contained in a collection of objects. The data was in the form of an generic List<T>, already loaded into memory. So without thinking too much about it, I sat down and wrote a quick LINQ expression that included the Distinct() operator and since the years were actually properties on the objects, I wrote my own implementation of IEqualityComparer.

It had some problems because the resulting data was not really all that distinct, and then it happened: PWOP!

I don't need to implement an interface. I can simply use the default equality comparer for a List<int> like so.

LINQ Distinct() Operator

Gah!

Thursday, July 31, 2008 9:52:54 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
LINQ

Behind the scenes, I see a lot of companies run on Excel and duct tape. So it's common for clients to hand me a slab of data organized into neat little rows and columns. Excel is just a handy way to throw some data over the wall and get things done. This might be a list of dealers, a collection of user profiles, product information, or anything that just needs to get somewhere else.

Depending on the scenario, I'll might massage this data and slide it into a SQL Server database or an XML file. I'm a web developer so I use the ADO.Net stack on a regular basis. If I were a Windows client developer, I might prefer to solve this problem with the Excel object model, but that really looks like more code to me, so here's how I like to roll:

The following code block accepts an Excel file path and returns an ordinary DataTable object, which can be manipulated easily by the code that calls this method. The first row of the Excel document becomes the columns in the DataTable object and each row thereafter are DataRow objects.

ImportDataFromExcel
(Click to enlarge)

If you like, take a look at both techniques for working with Excel data and see what one speaks to you. With this block of code, I can happily accept large chunks of data from a client without spending precious time fiddling with administrivia.

Thursday, July 31, 2008 8:00:16 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
asp.net | software | SQL Server | Visual Studio
 Tuesday, June 17, 2008

What's the deal with these online social networking sites? After you sign up, they casually ask for your credentials to other locations so they can provide some handy service. Jeff Atwood noted it recently, and I've just experienced it on Plaxo. Huh... That's nice, but no thank you, and please don't ask any of my friends either.

plaxo

Tuesday, June 17, 2008 9:44:21 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
security
 Wednesday, May 28, 2008

I noticed this when I left the house this morning. Le Wife dislikes the roses due to the maintenance they require and this isn't helping matters at all.

mean-roses

Wednesday, May 28, 2008 3:41:39 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
observations
 Thursday, May 22, 2008

Joel Spolsky (of http://www.joelonsoftware.com/) and Jeff Atwood (of http://www.codinghorror.com/blog/) selected my audio question on their new podcast, episode #6.

Stackoverflow is a new property created by a joint venture between these two blogging juggernauts.

http://blog.stackoverflow.com/

So far, their podcast is interesting like Paris Hilton. She’s famous for just being herself. Nevertheless, I am now famous.

I really do look forward to each new episode. Its a nice change of pace from the others that decorate my new iPhone. It's a little like a Seinfeld episode too, its a show about nothing, but in that span of 30 minutes, something interesting always happens. I love the history that Joel sprinkles in and the minutia that intrigues Jeff so much.

My question picked a little bit on Jeff, but hopefully the core of it came through. It was essentially a version of the eternal buy vs. build issue, or in this case "use what's in the box" vs. "build your own" scenario. Jeff had a respectable answer that centered on what he felt was important and what he was happy to inherit from the .Net Framework.

These are the types of debates I have every day building software. Its fun to ping someone outside your normal group every now and again and see what they have to say about it.

Thursday, May 22, 2008 10:35:52 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
asp.net | blogging
 Wednesday, May 21, 2008

Ok, so I'm not sure I've posted about the dog and the Thai food on this blog before, but I have been preoccupied lately with the newborn.

I was the proud poppa of an 8lb 15oz baby boy on April 29th, 2008. I'm still at a loss for words. This is arguably the cutest, smartest baby in the world.

baby

Wednesday, May 21, 2008 8:00:44 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -

About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2009
Andrew Hay
Sign In
All Content © 2009, Andrew Hay
DasBlog theme 'Business' created by Christoph De Baene (delarou)