Monday, October 31, 2005

Evil Getters and AJAX

    A couple of years ago, I read a great article by Allen Hollub called "Why getter and setter methods are evil." If you've never read this, I highly recommend it. Let me give a very quick synopsis. Exposing data via accessors (getters and setters) causes tight coupling between components in your code. So if something changes about your data, then many other components must also be changed to accommodate this change. So getters and setters are evil.
    That's all well and good, until we start talking about UI. Most of the UIs out there, whether they are desktop applications or web pages, use an MVC paradigm. This inevitably leads to your view calling lots of getters on models to display data. Similarly your controllers wind up calling lots of setters on models to process input. So MVC requires lots of getters and setters.
    So is MVC evil? That would be a problem because it is the de facto standard in UI technologies. Let's just concentrate on Java web apps for the moment. Struts and JSF are both MVC based frameworks. My new personal favorite UI technology, Spring MVC is also clearly and MVC framework.
    The more object oriented approach to UI would say that objects should know how to render themselves. If they know how to render themselves, then other components (views) do not need to call getters. These objects should also know how to construct themselves. So their components (controllers) do not need to call setters. This is clearly against MVC which says that the view of an object needs to be separated from the object.
    Holub's original article caused quite a stir. He stuck to his guns and presented an alternative approach to MVC in a follow-up article last year. Here he suggested that a Builder Pattern be used to build different representations of an object. This could an include an HTML representation to be used by a web app.
    This is a clever idea. I liked it quite a bit. However, when I read it, I could totally see an experienced UI developer looking at all of these builder classes that had a lot of nasty code to build HTML strings, and thinking "this is stupid."
    Something has changed this year that may change people's minds. That something is AJAX. One of the many things that AJAX encourages is the ability to render on a much more granular basis. You don't want to always re-render an entire when a request is processed. Instead you need to be able to just re-render the parts of the view that have been affected by the request.
    I saw an article on TSS about adding AJAX to an existing Struts web app. I couldn't help but be amused by their ridiculous strategies for doing this. They recommend re-using your view, but putting lots of if-tags in so that only parts of the view can be rendered based on data in a request. They then recommend using the request.responseText so that you can just dump the HTML from your view directly into your page.
    To me, this just shows the limitations of the MVC approach. The view object is the only thing that can be rendered, so everything has to go through it. These views are supposed to correspond to web pages, so a lot of hacking has to be done to turn a view into something that is not a web page and can be used by AJAX.
    What if you didn't have a Struts app? What if you had crazily taken Holub's advice and gone with a builder approach instead? One can imagine that your life is suddenly a lot easier. To use AJAX, you can easily just ask your sub-component to render itself and send that back to the JavaScript handler on the page. It can also render itself as HTML or as XML, allowing you to use the more powerful request.responeXml object. It is not only easier but much more natural to adopt AJAX to a web app that does not use MVC.

Tuesday, October 25, 2005

Flock

I'm writting this blog using Flock. There's been a lot of hype leading up to the beta release of Flock. It's been billed as Web 2.0's browser. It has built in support for a number of trendy sites, like del.icio.us and flickr and is built on top of Firefox. It also has a built-in blogger, that I'm using right now. So what's my opinion of Flock?

Flock is not-bad. It's a good idea to introduce a browser like this whose aim is to make it easier for people to push their own content to the web. It's integration with del.icio.us is a great idea. I could see that as a tool that a lot of people will use. Of course Yahoo! is trying to do the same thing with their My Web tools, and I'm sure Microsoft will follow suit (not so sure about Google.) This kind of tool fits more naturally inside a web browser. Yahoo! uses its toolbar to enable similar functionality, but not everybody has their toolbar or would even want it. To be sure, My Web has other cool features, but I still think Flock+del.icio.us is a better combination.

Having a built-in blog tool is not quite as much of a hit. The biggest blog-site, Google's Blogger, already has a pretty nice interface. For more advanced blogging, Google provides a MS Word plugin that works great. Still Flock has some nice touches. The one I like is the tagging. Tagging is an important part of Web 2.0 and it's nice that you can tag your blogs easily. Actually, they really need to make tagging easier when adding a site to your del.icio.us collection. One of del.icio.us's best features is that this is super easy to tag when using their bookmarklet, and they do a pretty good job of suggesting tags. Anyways, the blogging tool in Flock is not bad.

Now for my real complaints! This is one buggy browser. I installed it on my laptop and on my home desktop. I'm blogging from my laptop, partly because I could not get the blogging feature to work at home. I had a hard time getting del.icio.us integration working on my laptop, though it was easier at home. However, I get prompted for my del.icio.us password a lot on my home machine, but not on my laptop. Its performance is actually not as bad as I expected (Firefox + lots of extensions often becomes slow.) There are many other minor bugs. They've really got to get the blogging and del.icio.us integration working though, as those are their calling cards.

Technorati Tags: ,

Monday, October 24, 2005

Twenty-Four Hours of Seattle

This past Thursday night I flew to Seattle. I was there until Friday evening when I flew back home to San Jose. Why was I in Seattle? Well that's the subject for another blog that I will definitely write in the not too distant future. This was my first trip to Seattle, so that makes for a pretty good blog subject all by itself.

First off, I flew Alaska Airlines to Seattle. This was my first time flying Alaska, I was very unimpressed. Their terminal in San Jose and their planes all seemed like they had not been redecorated since the 70's. Both of my flights (to and from) were late. The flight attendants were especially annoying. They were like watchdogs when it came to making sure people shut down their laptops and iPods.

What I got really annoyed with was hearing about how there wasn't going to enough room for all the carry-on luggage. Why do they have a policy of one carry-on plus one "personal" item if they don't actually have room for that? They kept threatening to make people check their luggage. Then they would point out that if you had to check your luggage at the gate, you would not be able to claim at the gate (you'd have to get it from baggage claim) unless you were flying first class. How rididculous is that? Earlier this year I flew to Florida with my wife and one-year old son. We bought an umbrella stroller for pushing him around the airport. We would then check this at the gate when were boarding the plane. We would then pick it up when we were getting off the plane, so we could put him back in it. This was especially useful considering we had to change planes in Atlanta. I guess if we were flying Alaska then, we would not have been able to get our stroller back until we got to Florida.

Ok, so Alaska Airlines sucks. Next up was my hotel in Seattle. I stayed at the W Seattle. I was really looking forward to the hotel. It looked really nice online and it sounded like a place that really pampered its guests. This was exactly the case, but yet I was still very disappointed with the W.

The W is one of those places that tries way too hard to be cool. You've known people like that. They're not inherently bad, but you don't really want to be around them much. That's the W. The place is poorly lit. The hall outside my room was very dark, with only low-lit purple lighting. Yes purple. The lobby was dark with booming techno music. This was true when I arrived at 10 PM on Thursday night, and was still true when I went jogging at 7 AM on Friday morning. They like to advertise about the thread-count of the comforters on their beds and their goose feather pillows, but the most important part of a bed is the mattress. Their beds were way too soft. Maybe kids might like that, but most adults will wind up with a back-ache because of the lack of back support. Actually my wife likes super-soft beds like that, but she's the only adult I know who doesn't need back support from their beds, and the W's beds had no back support. The room did have a nice chair and desk. It also had a cool-looking couch that had soft cushions to sit on, but no cushions for the back. So you'd sit down, sink into the seat cushions, then tip backwards and hit the hard board back of the couch. The W is all about form over function.

But here's the worst thing about the W. Despite being a very nice hotel and very expensive hotel, they totally try to nickel-and-dime you. Things that are included at most nice hotels are not included at the W. They deliver USA Today to your door each morning, without you even having to ask. However, they charge you $0.80 for it. They have internet access in the rooms (though no Wi-Fi, which I found very surprising) but you have to pay $15 a day for it! My wife and I recently stayed at a Best Western in Cambria and it had free internet access in all rooms, with free Wi-Fi in most rooms and all public areas. That was a Best Western. You would think that a fancy hotel like the W would have at least as many amenities as a Best Western in central California.

Ok, so I also hated the W. Otherwise though, I really liked Seattle. I was impressed with the cleanliness of the city. I really enjoyed jogging downtown. Seattle seems like a big sports town. The new stadiums (Qwest Field and Safeco Field) are both very impressive. There were tons of sports bars. The weather there was beautiful while I was there. Everyone claims that the rainy-ness of Seattle is greatly exaggerated. Of course fall is generally a nice season in most parts of the country, but it was definitely quite nice in Seattle. I didn't get a chance to try much food there, and didn't even try any coffee while I was there. Maybe next time.

Tuesday, October 11, 2005

Oracle Buys Innobase

I was pretty surprised to hear about Oracle buying Innobase, makers of MySQL’s InnoDB engine. I’ve used MySQL/InnoDB many times over the years and have always had very positive results with it. Their combinations of speed plus data integrity (foreign keys and rollbacks) make it ideal for small scale OLTP systems. MySQL has numerous storage engine options, but I think InnoDB has to be one of the most popular.

So now the big question is why did Oracle buy Innobase? Many people fear that their only reason is to damage MySQL. Given Oracle’s reputation, this is not surprising. Perhaps they fear that open source databases like MySQL will start to eat at their profits (maybe they already are?) InnoDb is GPL’d, but like all MySQL products, they sell support. It’s the money from those support contracts that pay the salaries of the developers who write InnoDB. The MySQL/Innobase contract is up next year, so theoretically Oracle could prevent MySQL from offering support to InnoDB users. That support includes a hot backup tool for InnoDB, a real must for sensitive, high volume customers. So indeed, Oracle could wound MySQL.

Personally, I’m not completely convinced. Does Oracle really fear MySQL that much? If they do, then I’m impressed. Oracle’s never shown that kind of foresight previously. If this is the case, then it would be a strange combination of insight and ignorance. They would be insightful for expecting MySQL to erode their market share in their more profitable spaces. They would be ignorant to think that an open source project could be crippled easily. MySQL already has other transactional engines. There are also many other open source transaction databases out there. It would not be difficult at all for them to replace InnoDB. Their very architecture makes it easy from a technical standpoint. Sure there would be some existing customers affected, but it’s really hard to imagine those people dropping MySQL and switching to Oracle.

And that brings me to the reason why I’m not convinced Oracle is trying to damage MySQL. MySQL and Oracle do not compete directly as much as one might think. Sure there are definitely companies that consider both. I really don’t think there are that many MySQL installs out there where they would have gone with Oracle if MySQL did not exist. If those existing MySQL customers were running Linux (Linux and MySQL put the L and M and in LAMP after all), then they probably would have gone to Postgres instead (or maybe Firebird.) If they were running Windows, then they would definitely go with SQL Server over Oracle, because of the price difference and the fact that they could clearly live without a lot of Oracle’s features.

Basically I don’t think MySQL’s customer base currently draws from would-be Oracle customers. It’s mostly people who want something free that won’t require them to have a full-time DBA to make it work. They want the opposite of Oracle. The two databases really are at the opposite ends of the spectrum.

So maybe Oracle will actually try to strengthen InnoDB and thus strengthen MySQL. Think about how much more attractive MySQL could be if it could boast that Oracle had contributed to its transaction database engine. One could really see MySQL eating into SQL Server’s market share. Meanwhile MySQL could have a lot more support contracts, which in turn could make the idea profitable for Oracle too.

Thursday, October 06, 2005

Nano Nano

(Anybody get the Mork reference?)
In 2001 my wife bought me the first-generation iPod as a Christmas present. At the time we weren’t married, but after getting that kind of present, we tied the knot in 2002. That iPod has seen a lot of use. For years it was my companion on my long commute from the East Bay to Silicon Valley everyday. It was also my companion on numerous personal and business trips across the country. More recently it has been my jogging companion each morning.
Earlier this week, I retired that iPod and finally bought a new one. I bought a 4 GB iPod Nano. As I mentioned, my primary use of the iPod now is for jogging, so the Nano seemed like an even better iPod for that than the iPod Shuffle. For $50 more I could’ve gotten a 20 GB fourth-generation iPod, but the Nano is far better suited for jogging. I rip my songs as high quality VBR MP3s using Lame, so I’ve only got about 500 songs on my Nano. So I sync it with a playlist in iTunes, as my full music collection is over 30 GB in size.
Anyways, I couldn’t be happier with the Nano. It’s really hard to believe how small and light it is. The wheel is very easy to use and the screen is bright and easy to read. It looks like anti-aliased text on the screen actually, a very nice touch. I’m planning on picking up the Nano lanyard to make it even easier to use while jogging.
As for my venerable old iPod, I’m not sure what is to become of it. It still holds a decent charge (~90 minutes, at least while jogging) and is in very good condition. I checked eBay and it looked like I could probably get $50+ for it, but I don’t know if I’d want to sell it. I’m not a very sentimental person, but maybe I’ll just have to keep it around.