Wednesday, May 30, 2007

FolderShare

Here's something I've been using for some time now, and I think it's great - FolderShare. It's a way to selectively exchange files with users that you invite (versus using a global P-to-P type of sharing where anyone can see your shared directory).

It is owned by Microsoft now and is still in "beta" even after a couple of years, but it works without a hitch. Almost. (see below)

I have a directory on both my home and work machines that are connected in a "library". When I find an interesting utility that would be useful at home, I put a copy in that folder and the transfer happens automatically, in the background. Naturally, the sending and receiving machines have to be running the FolderShare program, but I rarely turn off either machine.

Not only that, but you can have multiple users sharing the same folder. It's kind of like RSS for files, only you control who can 'subscribe' to the directory.

One of the really nice things is that it works behind just about any firewall because it's port 80 based!


Now, the hitch. In theory, you can visit the web site and browse another machine's shared directories (the site is password protected, of course). If you click on a particular file, it will initiate a file transfer. However, I have had only mixed success with this. Sometimes it will just sit forever, sometimes it will timeout, sometimes you get the file. Size (in this case) doesn't matter.

And in my case, the chums who control the firewall have added this site to the blocked list under the category "Peer to peer sharing sites". I've put in a request to have it unblocked, but it looks like they won't do it. But the folder sharing auto-transfer feature is just great and works flawlessly.

Tuesday, May 08, 2007

What's so good about NHibernate?

I work with data quite a bit and am always a sucker for on the lookout for new ORM/code generation tools to help automate cruds and queries. For a while now it has been MyGeneration d00dads. Free (always a good thing, since I work for a non-profit), fairly shallow learning curve, not too many quirks. But you never know when something better might be waiting for you Out There.

I have seen several items lately, particularly from Ayende of course (I love the idea of Bumbler!) Sam considers it Noteable. In the past, he has also mentioned it in contrast to Microsoft's flagging ORM efforts as a Good Thing.

Time to check it out. I go to NHibernate.org (or rather a page off of Hibernate.org) and check out the Nhibernate Quick Start Guide. In five steps, the first of which you may not need (create a database), the last of which is really several steps to get the configuration and connection objects lashed up, you can begin firing at your database.

The first few examples look good, such as:
User newUser = new User();
newUser.Id = "joe_cool";
newUser.UserName = "Joseph Cool";
newUser.Password = "abc123";
newUser.EmailAddress = "joe@cool.com";
newUser.LastLogon = DateTime.Now;
session.Save(newUser); // commit all changes to the DB
transaction.Commit();
session.Close();

Seems natural enough. Then we go down a bit to find

Let's say you want to retrieve an object when you know the user ID (eg. During a login process to your site). Once a session is opened it's a one-liner; pass in the key and you're done:

// open another session to get the new user
session = factory.OpenSession();
User joeCool = (User)session.Load(typeof(User), "joe_cool");


Casting? Why are we casting?? Why not create an object of the type you want and get IntelliSense for its columns, properties, and methods? That's what the MyGeneration d00dads architecture lets you do. Here is their canonical example.

And what's up with all the code you have to write? One would assume that NH devotees use code generation for the class with its properties and the XML mapping file that has to be embedded in your assembly. But no mention of it in the quickstart. If I thought I would have to do all that, I would give up right away. (As it happens, MyGeneration has a template that does the class and .hbm.xml file. If it didn't, I would surely be writing my own.)

Now a lot of any ORM or DAL tool is what you get used to doing. If NH floats your boat, I won't try to argue you out of it. But I'd love to know if anyone using NH has also tried something a bit more automated, perhaps even SubSonic, which is starting to look very nice in v2.0.

If you have tried something else and still use NH, I'd love to know why.