Comparing ATLAS with YUI

I recently attended a introduction to the Microsoft AJAX libraries (‘Developing Compelling Sites and Applications’), formally known as ATLAS, and thought I’d compare that with some of the work I’ve done with the Yahoo User Interface (YUI) libraries.
 
At first you’d be forgiven for thinking that ATLAS is all about asyn’ communications between a browser client and the server. Of course you’d be correct, but it’s not all about that. As with many technologies its primary aims quickly gets lost in time. One of the reasons technologies such as AJAX came about it give the user a better, dare I say desktop, experience. One of the obvious problems with that is how to update a web page with new details from the server. This is where the popular view of ATLAS comes in, focusing on how the client/server communications work. However, the often overlooked part is how to do I change the client presentation given all the different sorts of browsers out there? To use ATLAS terminology this is known as the client lilbraries. Both YUI and ATLAS share this ground and this is the area I’m going to quickly review.
 

Object or UI Orientated?

Both libraries have implemented their own…style…for providing a more OO feel to the JavaScript code and to introduce some extra programming techniques, e.g. Namespaces. However, I believe that ATLAS goes quite a lot further. It allows you to register classes (including base classes), interfaces, enums etc. Although YUI has some of these features it feels very much more like YUI includes them to support the UI whereas ATLAS has included them to produce OO like code that happens to be used in the UI. A subtle but important difference, although if I can get the UI working without worrying about the code perhaps the Yahoo! way is better? If you’re a .net programmer now I’m sure you’d feel at home with the ATLAS client…code extensions(?).

UI Features

Both libraries have a very similar set of features but I’d say the YUI is more mature than the beta ATLAS counterparts. The YUI components just seem to work as you’d want. When I launch a panel in the YUI I get the full dialog experience with options for title bars, modal dialog, move controls, etc. Whereas for ATLAS I seem to get a square that I can move, but I’ve got to add the mouse pointer, the title, etc, etc. Another example is the Auto-complete edit box. The YUI and ATLAS variants do pretty much the same job, however the YUI includes a "selected" event, whereas I seem to have to code that myself for ATLAS. This means that I can quickly produce pretty slick UIs with YUI that do 90% of what I want. However, here’s the bind. When the YUI component doesn’t work as intended it takes quite a bit of fishing around to understand how the component works to sucessfully alter its behaviour. Whereas with ATLAS you learn that up-front and changes are easier because it works as you programmed it to. Ok, that’s a bit unfair, with the ATLAS control kit you can pretty easily wrap core features to become something more like what you need out of the box. However, I still come back to thinking that the YUI did almost everything I wanted without any need to customise it.

Summary

With my short time spent using both sets of libraries I’d have to say I’d probably invest my time in ATLAS. Mainly because it seems like the logical path to take when developing Microsoft based solutions, especially when you take into account ATLAS’ XAML like script, surely the tools will eventually all come together. However, at this very moment in time I would say that YUI wins hands down for its easy of use and feature set. I thought I’d struggled to get around animation bugs in the YUI, well I’d not seen the ATLAS implementation!

I’m sure over time both libraries will improve and it will probably just come down to the sort of coding you need to do. If you’re a Microsoft shop I’m sure ATLAS or Microsoft AJAX Client/Server/Control libaries will be for you.

 

Problem with SqlCommand.DeriveParameters

SqlCommandBuilder.DeriveParameters is a helper function that returns the parameters used by a stored procedure, a bit like the old ADO Command.Refresh. However, there is a problem with it. Consider the following stored procedure…

Create Proc Bob.MyProcTest(@Name nvarchar(100))

as

select ‘hello’ + @Name

 

and…

Create Proc Fred.MyProcTest(@Name nvarchar(100))

as

select ‘hello’ + @Name

 

So we’ve got the same procedure differing only by the owner. When you ask SqlCommandBuilder.DeriveParameters to fetch the parameters it incorrectly returns 4 parameters rather than two (remember that the return value is counted as a parameter). It’s fairly obvious why but it shouldn’t do it and can, as I’ve found to my cost, easily cause problems.

[Edit] I’ve since been informed that if you prefix the stored procedure name with the owner it works fine. It does, and that’s certainly better than nothing, but I still believe returning an appended result could never be the correct the answer. SqlCommand.DeriveParameters is there to aid in constructing calling code so I believe it should always make useful answers, so if the params match it should only return one, if they’re is more than one possible set it should raise an exception and ask you to be more specific.

How do I use GetDate() in a Function?

I’ve been writing a User Defined Table (UDT) function based upon user defined conditions. One of the valid conditions utilises GetDate() to discover today’s date. However, if you simply use GETDATE() in a function you’ll get;
 Invalid use of ‘getdate’ within a function.
 
This is because you cannot use non-deterministic functions within a UDT. The "correct" solution is to pass the GETDATE() value as an argument to the function, however, this requires that I change all the calling code and I don’t want to do that, besides why should I!
 
So my workaround is to create a fully fledged SQL table whose role in life is simply to return GETDATE()…
 
CREATE TABLE [dbo].[DummyDate](
            [Today]  AS (getdate()),
            [Dummy] [nchar](1)
)
Then within the function you can access the value by…
declare @TodaysDate datetime
select @TodaysDate = Today from DummyDate

Lynton/Lynmouth

Just got back from a short break in the Lynton, a small harbour town on the edge of Exmoor. It’s a great little place, especially if you’re into walking, if you can’t walk up a hill I’d think twice! I’m sure a photo blog/site will follow but if you’re thinking about going there then I’d recommend staying (or at least eating) at St Vincent Hotel & Restaurant. The food was excellent and really well priced, be warned though, you must book it quickly because we missed out on one evening.
 
Oh and one thing they don’t mention, they have free WiFi too!
 
[Edit] Lynton Photo site is now available. The web site design was carried about Clear Breeze Design, a Hampshire company based in Hook specialising in accessible web sites.

YUI – Yahoo! User Interface Library

YUI – Yahoo! User Interface Library

One of the few interesting sessions in this years @Media 2006 event was on how Yahoo! were writting a core User Interface library called YUI. The library is free to download and the site contains some interesting demo’s. It just so happens that I’m writting a very quick staff database to allow people to put a picture to a face at work. So I set about using YUI…
 

What is YUI?

YUI is a set of javascript files containing useful UI code that are downloaded to the client in the normal "script src" fashion. The libraries build on themselves to provide ever richer UI tools.

The type of tools on offer include;

  • Event registrations
  • Dom support
  • Drag n’ Drop
  • Calendar
  • Menu
  • TreeView
  • AutoComplete

My favourite is the Container that provides a very simple mechanism to include your own dialogs on a page, including psuedo modal windows.

My Staff Database

The project I wrote using YUI was essentially a very simple contact list with the following basic structure;

[Edit Box] [Find Button]

[Name of person] n [Contact details]n  [Photo]n

[Name of person] n+1 [Contact details]n+1  [Photo]n+1

etc

The Edit Box for searching for a persons name is implemented as an AutoComplete control, so as you type in the persons name it displays a list of ever more specific matches. When you find a match, you click the Find Button and the page is scrolled to the person in question and their name is animated to draw the users attention. The user can then see the thumbnail image of the person and can click on the image to see a larger picture. This invokes a photo-box dialog that displays the picture in a modal dialog without the user having to leave the main page.

 

Any problems using YUI?

YUI isn’t without its problems.

Documentation

When I started using YUI it was in a beta form so the help was a bit sparse and even though it has been improved I still needed to fish around inside the implementation libraries to understand what I needed to do.

Style

I’m sure Javascript must hold some kind of record for the number of ways to define a function block and I’m equally sure people will argue for weeks about which style is best to use. However, what I would expect from library code (of which I include the example code) is a consistant style. I’d just got used to one style in the ‘Module’ code to be faced with a different one for ‘AutoComplete’. Ok it’s a minor thing but it’s pretty irritating, if not tricky, to read a block of code with different coding styles within it.

Stylesheets and Javascript

Obviously a Javascript library needs Javascript to work, but it does need to placed into the ‘problem’ section since there are server side alternatives to many of the YUI features. I chose to degrade gracefully when there is no javascript by defaulting to a fairly standard HTML version of my page and getting Javascript to add complexity, that way if there is no Javascript then you only get the basic feature set. The slightly trickier problem is the use of Cascading Style-Sheets (CSS). For me, one of the great goals of CSS is that it should degrade gracefully. YUI relies on CSS to provide many of its features, some degrade more gracefully than others. For example, the auto-complete list is a hidden list, turn off stylesheet support and the list is created underneath the edit box. Ok it’s ugly but functionally it works fine. However the containers don’t really work. In my example the photo-box simply stays at the bottom of the screen and is pretty useless. More annoying is the use of colour. I wanted to write a colour fade (or animation) but this required me supplying the colours I wanted to use. Now I can’t really do this since the user (or other developer) maybe using a stylesheet that I’m not expecting. YUI provides some support for detecting the style of an element but this didn’t work as expected. When I asked for the background colour of a specific element it failed to properly traverse the CSS hierarchy and only provided the correct answer when the element was specifically configured in the stylesheet. That led me onto another annoying problem, my workaround was then to use an opacity fade but that kept doing odd things to the font. Eventually I discovered that you must ensure the text in an opacity fade has a background colour.

The other major problem with the CSS use is how accessable the page is. In my example I had to add extra buttons and events to cope with the keyboard user. Reading between the lines it looks like the YUI is doing more in this area but currently I feel you have to add too much of this code yourself.

Extending the YUI

Apart from the coding style issues I found extending the YUI relatively easy. The main problem is due to its main advantage, the coupling of the modules hides the complexity of the lower-level libraries but it can also means that you can break the code without really knowing why. In my example I have pictures of different sizes to display within my photo-box, so I extended the module to allow me to specificy the dimensions of the image. This worked fine for a while but suddenly the box refused to be moved by the user and would just stutter. Also if I created a dialog larger than the viewport it started to behave erratically. I’m still not sure what caused this, perhaps beta code, but after a re-write for the latest version it seems to work.

Summary

I think the YUI is well worth a look but I do get the feeling that the majority of the features are built for users with a monitor and a mouse. Then again there is nothing stopping you extending the library to better cope with other devices. So even though it isn’t perfect I’m certainly considering using it in future projects.

Trouble with Dell 2007FP

My trusty Diamondtron 17" CRT finally started to give up the ghost. So armed with a great review (for it’s larger brother) I (brashly) purchased a new Dell 2007FP 20.1" LCD.
It arrived the following day (good start) and I unpacked it. Spent the usual 10 min unplugged loads of cables and contorting myself into knots feeding the new cables around the back of my desk. Then it started, my bad luck with the monitor…
1. No power cord
Oh great no power cord, so the last 5 mins of unthreading the CRTs power cord is now a total waste of time since I’m going to be forced to re-use it. Not a big problem but just one of the annoying things
[Edit 4-Sept] Overclockers emailed me apologising for the problem and have promised to ship me a replacement cord.
2. Clear Type halo
Installing it was pretty easy, XP took to it well. The text wasn’t so great, something I’d worried about since at 1600×1200 the text was always going to be small. But I’ve not engaged Clear Type…eeew, a horrible redish halo around the text. Now my 17" Dell LCD at work has exactly the same problem, something I’d put down to as the rubbish bottom of the range ATI card + rubbish Win 2003 ATI drivers. But alas not, my top of the range (well about 3 years ago) 9800XT plus decent XP drivers can’t be at fault here. Surely the various glowing reviews for the monitor would have seen this…
3. Samsung vs Philips
Apparently the guts of 2007FP is manufactured by two companies, Samsung and Philips. However, the real crunch is they use two very different technologies, sure they meet the same spec’s but their implementation is totally different. The Dell forums are saying that its basically a lottery, the Philips is the better image quality with the Samsung probably being faster for the gamer. Although I do play far too many games I really wanted the image quality…guess which version I’ve ended up with? Yep the Samsung. Could this be the reason for the dodgy Clear Type? The forums also went on to say that the rumour was that the press were only ever given the Philips variant, hence the good quality reviews. I feel a tad bit conned.
4. Stuck Pixel
Ah the final straw (I so hope it’s the last problem), a stuck pixel. Even on the huge real-estate of 1600×1200 that ***** pixel screams at me. Hopefully Dell will take it back, lets hope so…maybe I’ll even get a nice Philips IPS version in return too…’cause I’m just that lucky 😉
[Edit 4-Sept]Oh no they won’t. Unless you screen looks like it’s been in a shotgun hunting accident they won’t take it back. Still I have some better news…
[Edit]
Clear Type – Attached a Dell laptop (NVidia chipset) to the screen today to see what the Clear Type looked like. I have to say I think it does a better job. Still no-where near my (now elevated to lovely) Sony 17" SDM-X Black but better than the ATI source. However…the laptop is using the VGA vs my desktop’s DVI source. In theory the DVI should be better but I’ve seen plenty of reports with monitors (esp. Dell) having problems with DVI. Next steps will be to rig up an NVidia DVI source and switch the ATI to VGA.
Stuck Pixel – used some "flashing colour" techniques to wake the pixel up. No joy, I quite like the theory behind the fix, apparently PSP owners have had some joy so I’ll try it out for a bit longer. Strangely the tiny 5×5 flashing square is less distracting than the stuck pixel, I guess at least it looks like it’s doing something!?
[Edit 4-Sept]
Well I swapped the screens over and and it seems to make a huge difference. The trusty Sony SDM-HS75P works a treat using the ATI DVI source, so that takes the pressure off ATI a bit and back onto the Dell. Meanwhile I plug the Dell into the NVidia 6800GT DVI source…well not too bad. A quick application of Microsoft’s Tweak Clear Type and it looks usable. In fact it looked better before I’d even realised I was still running at a lower resolution…that’s the sort of difference the NVidia card makes.
So my conclusions are quite surprising, it seems that the worst thing you can do is pair up a Dell monitor with an ATI card, at least a fairly old ATI card, since I have a similar set-up at work and that’s terrible too then I think it is more than just a coincidence. However, the NVidia card seems unfased by the monitor as does the Sony. So my advice is, if you must use Dell then look at NVidia, if you don’t want to take chances go with Sony. NB. I bought the Sony because it was one of the few I could try before I bought, and the Sony below the HS75P wasn’t great either so my best advice is try it first!

Has Bool flag had its day?

I was reading a collegues code review the other day and they raised the point that they didn’t understand what the new parameter in a call meant. The reason for this was the new code simply stated something like:

MyMethod(Name, Address, true)

Naming conventions means the first two arguments do a good job of conveying what they are supplying to the method. The problem with the third argument is it’s more of a statement rather than a hint to its (ahem) true meaning. The proposed solution was to swap this out for a enum; UpdateProcess.New | UpdateProcess.Edit Ok I can see how that might work, but the obvious point that seemed to have been missed is why not simply use a variable? If I rewrote the call using a variable for the Boolean wouldn’t this sort out the problem?

MyMethod(Name, Address, isNew)

Well to some extent it does, at least now the reader has some clue to the intent, however, if true==isNew what does false mean? What is the opposite of isNew? Ok you’ve read that the intent is to be new or edit, but you’ve had to discover that by some other means, the code doesn’t not convey that. You’d have to read a comment or drill down into MyMethod to understand that. This is where the (ahem..again) argument for a enum gains the upper hand. I’ll re-write it again.

MyMethod(Name, Address, UpdateProces.New)

Once again we can see what the caller wants to do a "new", whatever that is. But now the reader (assuming a decent editor) can hover over UpdateProcess and see what the alternatives are, in a binary case such as this then there are only two, previously represented by true/false. But now the reader has a chance of understanding the authors intent.

So what this long-winded blog entry is trying to say is, "do we need Boolean flags now?" I don’t think there is much need for them now, so I’ll shed a little tear for a faithful old friend and usher in more of those ugly type-space-hogging enums. I guess this is progress. R.I.P bool flag.

Upgrading Photoshop CS2 to Creative Suite 2 Standard

Decided to the a copy of Adobe Illustrator was needed to compliment Photoshop so called Adobe to ask about the options. The best all-around option was to upgrade from Photoshop to Creative Suite Standard 2 (CSS2), about the same price plus you get InDesign too.
 
So the package arrives and I start to install it. "Please uninstall the following…Photoshop CS2". Hmm, ok. "What do you want to do with your activation information?", erm spose I should keep that…why doesn’t the upgrade pack tell me what to expect?
 
So after uninstalling (and rebooting) I try to install CSS2 again. After entering the serial number, again, it asks me how I want to locate my copy of Photoshop 5 or above. Ok, I put the Photoshop CD in the drive and say, "search CD drives". "Not found". Hmm, try the other options to be faced with the same result. Grr, so I re-install Photoshop and try again.
 
"Please uninstall Photoshop" – Ha, not likely. "Continue".
"Photoshop is installed, press Quit to quit the install". No! "Continue".
"How do you wish to locate Photoshop?". "CD" – "not found", all the other options, "not found".
 
But hang on, you’ve just told me twice I’ve got the thing installed and now you can’t find it!!! So I hit browse and lead the horse to the water. Hurray, it worked off we go. Good grief and I thought installing Quark software was a pain in the seating area. So the trick seems to be, don’t uninstall Photoshop CS2, no matter how much it begs you to. Although, I’ve yet to start using it earnest so who knows what awaits me.

House for sale

Looking for a property outside of London, near Leatherhead, in leafy Surrey? Why bother with pesky estate agents, go straight to the source.
Why not take a look at this house for sale in Bookham 

www.paddockview.eu

 

Microsoft Expression Interactive Designer

Ran through a simple Tutorial today using the Beta of Expression Interactive Designer. It’s quite an odd experience, sort of like a cross between a image tool and a traditional Windows form designer, at least as far as the UI is concerned. However, the tutorial wasn’t without its problems.
 
Problem 1, "Namespace is incorrect, please change root namespace element in the project". When I ran the tutorial I got a very strange error. This shows one of the major drawbacks of this tool. Essentially what I guess had happened is that at some point I’d been forced to "Save As" and used a different name, "Fabrikum Tutorial2". Unbeknown to me this create a rootNamespace element, in the actual project file, called "Fabrikum Tutorial2". So after fishing around with the C# code produced (via notepad) it dawned on me that it was using "Fabrikum_Tutorial2", i.e. no spaces. So I manually changed the project by inserting the underscore and hurray it compiled. Now I’m not suggesting that I’m some kind of developer super hero but this tool is aimed at UI designers who shouldn’t have to care about c#, that’s really the point of it. So why show bizzare errors that mean nothing and can’t be fixed without getting low down and dirty with the code. Oh well I guess that’s Beta software.
 
Project 2. Data binding. The first example gets you to set up a number of data bound controls. However, it didn’t work. The automatic synchronising between master and detail panes simply didn’t happen. Opening the finished sample of the code I tried to compare the XAML produced. Now I could see differences but I had no idea how to get these changes via the designer. That’s how I left it, tutorial 1 complete, but with it not working. Score another one for the Beta product, but you’d think at this late stage a simple tutorial should work.