Favourite blogs for Hannah's handbag

My favourites » All entries

August 28, 2008

David Tucker's 10 common mistakes when building AIR applications

David Tucker recently posted an article on the Adobe Developer Centre citing 10 common mistakes with developing AIR applications and how to avoid them. I thought I’d quickly compare David’s points against my current AIR project, a remote file-system/transfer manager:

1. Making an application platform specific

David primarily refers here to the UI/UX differences between platforms, but I also found it essential because I encountered significant performance differences with some file system operations (icon getters, mostly), which were fixed with the help of the Flex Profiler. At the moment we can’t test it on the Linux Alpha, but hopefully we’ll be able to try that soon.

2. Not including update capability in an application

We included this as soon as the framework became available and it works very well – whenever the application starts it can check for a newer version of itself, and the user has control over whether to update or not.

3. Changing the application ID after an app has been released

Oops – I ran into this early on; changing the application ID means the update framework will break, amongst other things. Changing the name of your application halfway through the project also risks confusion.

4. Not planning for offline support

Our application relies on a live connection to work, but it does use AIR’s network monitoring APIs to check for a valid connection at startup and then continually monitor connection status, and warns the user if connectivity is lost.

5. Not thinking in AIR

I didn’t find this too difficult – some things were relevant and others weren’t. There have often been moments where I’ve discovered a capability and thought “I didn’t know it could do that”; we do use the application storage directory and the user’s temp directory for file transfers though, and the File , FileStream and FileReference classes were the key to making it work.

6. Using custom chrome to create confusing interfaces

We used the standard chrome, but most of the AIR applications I’ve seen that use custom chrome have done so pretty effectively. One of the most powerful aspects of AIR is that you have very fine control over the UI. As a counter to this though, in addition to the native window chrome there are valid use-cases for having access to native system controls, like toolbars, buttons etc. – platform UI differences can make this even more acute, so I’d like the ability to use standard UI elements where appropriate.

7. Not using the seamless install badge

We implemented this early on – having an install badge makes installation a snap for most people and like the update framework it works well – installation of the AIR runtime can be managed automatically and so far the whole thing has worked fine, except when I broke it myself by not updating the right fields in the updater XML file.

8. Not encrypting sensitive data

Not relevant for this application (yet) – we don’t store any information other than the last file-space used, using a standard SharedObject. AIR has an EncryptedLocalStore for this kind of thing though.

9. Not preserving native interaction

As yet we haven’t got a complete set of keyboard interactions in place (e.g. cut, copy and paste) but some are there. The core interaction type is dragging and dropping, and Flex/AIR gives you control over the process by splitting this action into discreet event-driven stages, so providing visual feedback about whether a drag/drop is allowed can be controlled via your own logic. Something I’ve not yet overcome is how to work with internal and external drag handling at the same time – I may be wrong here but so far it looks like the external drag management only knows about drag in/out operations at the application level, not at the component level, so I need to work on how to use the external drag management to allow items to be dragged into components with the same level of control as the internal drag manager.

A more difficult problem is when a standard component doesn’t quite mimic the operation of a native system control – take the Tree for instance, which will close when its DP is refreshed – in situations like these its nearly always possible to closely replicate the native behaviour by extending or over-riding the component default, but there can be some work involved when finding out what to do. At this point I’ll thank Peter Ent and the excellent Flex Examples Blog for their invaluable resources; they saved me a lot of time.

10. Assuming performance doesn’t matter outside of the browser

In this case, the performance issues highlighted when checking across platforms also highlighted the importance of using the Flex Profiler, the net result being a five-fold increase in speed on OSX and smaller but useful increases on Windows, plus reduced memory usage. The original performance on OSX was bad enough to almost make the application unusable, but after identifying and fixing/working around the problems, the application performs similarly in Windows and OSX.

Thanks to David for writing about what to avoid – fortunately most of them we’d already come across and fixed, so that’s good!


August 19, 2008

FlexCamp London, Aug 28th

Writing about web page http://www.flexcamp.co.uk/

I really want to go to Flex Camp London but I can’t, so I’ll plug it instead because the programme looks great, the event is free and maybe someone will send me a free t-shirt :-)


July 18, 2008

On Dialogue Boxes…

I’m currently writing a few dialogue and interaction menus for my current AIR project, and the thought had occurred to me that having established a reasonable methodology for handling and displaying modal dialogues within my Cairngorm-based app, I was perhaps using them almost by default, without thinking too carefully about whether a modal dialogue was the most appropriate means of interaction. By modal in this context we mean “A state of a dialogue that requires the user to interact with the dialogue before interacting with other parts of the application or with other applications”.

At the same time, Chris and I have been talking about metadata recently (another entry to come, but the premise was that persuading users to input metadata about assets is hard to incentivise). Related to that, Chris sent me this great link to an entry by Jeff Attwood that in turns talks about an entry by Eric Lippert on how dialogue boxes are perceived by users:

* Dialog boxes are modal. But users do not think of them as “modal”, they think of them as “preventing me from getting any work done until I get rid of them.”

  • Dialog boxes almost always go away when you click the leftmost or rightmost button.
  • Dialog boxes usually say “If you want to tech the tech, you need to tech the tech with the teching tech tech. Tech the tech? Yes / No”
  • If you press one of those buttons, something happens. If you press the other one, nothing happens. Very few users want nothing to happen—in the majority of cases, whatever happens is what the user wanted to happen. Only in rare cases does something bad happen.

In short, from a user perspective, dialog boxes are impediments to productivity which provide no information. It’s like giving shocks or food pellets to monkeys when they press buttons—primates very quickly learn what gives them the good stuff and avoids the bad.

I liked that, especially the bit about “Teching the tech” – while it’s quite funny it’s also a pretty accurate reflection of my experience as a user.

This is also related closely to what Chris and I were discussing about metadata; expecting the user to fill in information that has no obvious purpose and slows down the primary task of upload/publish or whatever it is that they are trying to do, is likely to be ignored. If those fields/dialogues are modal or conditional, it’s worth thinking carefully about whether there are alternative ways to complete the operation or gather the infomation. That’s harder to do of course, and there are cases where modal dialogues should be considered appropriate, e.g. where the application is about to do something destructive like deleting or overwriting a file, but there are alternatives, like how IE and Firefox avoid breaking the flow of interaction when blocking certain actions.


July 01, 2008

Flash SEO, Adobe manoeuvres

Kudos to Adobe, Google and Yahoo for creating the mechanism for Flash content to be indexed on search engines. With one or two reservations (like how to distinguish between application content and a site) I think this is another significant move towards maintaining the ubiquity of Flash. It seems as though Adobe is steadily, but impressively quickly, removing piece by piece the most-cited drawbacks of Flash. Some of the most significant announcements (in no particular order):

  • H.264 video support
  • Open-sourced Flex SDK, BlazeDS
  • Opened access to Flash Player APIs
  • 3D support (thanks to Papervision, Away3D etc.)

Obviously it doesn’t take a genius to work out that, in part, Adobe has had to make some of these moves – HTML5, advances in Javascript and browser technologies promise or already offer many features that up until now Flash had to itself; the canvas and video tags in HTML5, DHTML effects, processing.js, SproutCore, the list goes on – it was inevitable that some of Flash’s functionality would be adopted and integrated into other technologies, but I think that those people who still maintain that they ‘hate Flash’ should still agree that it has been a primary driver of change on the web. This is particularly true in three areas; animation, user experience and video. Flash may responsible in their eyes for evil banner ads and inaccessible sites/UIs, but those things are created by people, and a technology that provides a degree of creative freedom is open to abuse – there are plenty of bad DHTML sites around and more than a fair share of annoying DIV-based floating ads out there already, but there is also a great number of fantastic and successful experiments in user interface design, animation and application experience. Flash has enabled developers to do things on the web they could not have easily done by other means, and those people that attribute bad practice to Flash are both ignorant and in for shock if they believe the same things won’t happen when other technologies catch up. Up until now it’s been far too easy to blame Flash, when Flash isn’t the problem. Use it where it works, not where it doesn’t (like whole sites).

In addition to the technology itself, Adobe has provided the means to develop and deploy it effectively, with the Flex SDK and FlexBuilder. Personally I have no objection to proprietary technologies when they a) work, b) don’t break anything and c) positively drive change and allow people to do things that standards-based technologies often take much longer to enable (and often not quite as well). Flash and Flex won’t be the standard, they will peacefully co-exist with other technologies (along with man, and fish); a single unified standard just isn’t possible in a competitive world, nor is it always desirable. Someone has to innovate, and attacking Flash (or Apple come to to think of it) for being proprietary is like attacking Ferrari for making a better sportscar (and charging for it). If it enables you to go faster, better, and (similar to Java and JS) is on 90-something% of desktops, who can blame Adobe for adding features and functionality that will maintain or increase edge and adoption? And at the same time if it is making key components of its platforms open, regardless of motivation, it’s A Good Thing*. So long as the standards do catch up, it’s fine.

There is I think, one thing left to do at the moment, the final hurdle as I see it – accessibility. It’s kind of in there, but if Adobe could make Flash and Flex as accessible as a typical web page, or at least as easy to make accessible as a web page, it would remove the one last stick with which it gets beaten. In fact and to bring this full circle, the same mechanism by which search indexing now works may also prove the key to unlocking accessibility, so maybe that’s already possible?

*None of these arguments apply to Microsoft, especially the Ferrari analogy. Silverlight is neither better or faster.


June 02, 2008

Yahoo BrowserPlus and AIR

Writing about web page http://browserplus.yahoo.com/

Yahoo has entered the RIA domain with BrowserPlus, a technology that allows you to create functionality that bridges desktop and browser. Some reports I’ve seen say that BrowserPlus is a direct rival to AIR, but from what I’ve read on the Yahoo site I’d say it sits closer to the browser than the desktop, like Gears; applications are still browser-hosted, whereas AIR sits more evenly between the two (albeit with much stronger emphasis on applications being system-based), but I’m wondering how many more niches there are left to fill in the RIA paradigm. BrowserPlus does offer some genuinely useful capabilities that are similar to those offered by AIR, like file drag/drop and system tray capabilities so comparisons are inevitable and in some ways justified, but these are currently a limited subset. An area which I think does justify close comparison to AIR is the development ‘gateway’, simply because both technologies allow HTML/JS developers to create RIAs with their existing skill-set.

If it’s easy to detect the existence of the BrowserPlus runtime within a page, it could get some traction; on our own web applications I can see it being useful to provide users who have it installed some extra functionality, like dragging and dropping files to the browser, or page update notifications, but it would be important not to rely on it being there for core functionality, partly I think because it would be harder to persuade users to install something that isn’t so ‘tangible’ as an AIR or Webstart application. Security may also be a concern – AIR and Java applications need to be digitally signed whereas it’s not clear yet what Yahoo will do here. I guess though it will depend on how useful and ubiquitous applications built on BrowserPlus become, and Yahoo has some fairly prominent applications for it within its own portfolio (e.g. Flickr). AIR is fast approaching that stage I think – Ebay Desktop, Google Analytics AIR, Twhirl, Adobe Media Player and Snackr are now core applications for many people I know, and the new and rather lovely Acrobat.com suite (and not forgetting Aviary) will be a major driver for further adoption, especially if the the AIR version can be extended to include desktop versions of the applications. I’m sure Yahoo will have the detection aspect covered – in addition they have done something similar to JavaFX with an extensible runtime that can be added to without re-installation, so it’s really only a case of getting that important first-install.

One final thought – it seems to me that if you could combine BrowserPlus with Prism you would have something closer in concept to AIR, if not execution; a browser-based application that looks like a desktop application, with a desktop integration runtime on top.


May 29, 2008

Features vs Functionality

I’ve just spent a few days trying to implement a specific feature in my current AIR project. Having tried several approaches and workarounds with varying degrees of nearly-but-not-quite-ness, I’ve had to admit defeat for now and have moved to a different implementation that I’m less happy with, but still allows basic functionality. At the same time Kieran has recently started work on his first Flex project and it’s been interesting to see how an experienced developer, when faced with a feature or issue he can’t easily implement or find a solution for, has quickly fallen back to a ‘next best’ solution, and moved onto getting the application functional and usable.

Time pressures obviously play a part here – the amount of time you have available before the project has to go out the door is going to impact on how much you are able to include desirable features over essential ones, but I think what I’ve picked up from this is that as soon as you encounter an issue, if you can’t predict reasonably accurately how long it’s going to take you to solve it, you need to set limits on how long you spend trying to make it work and at same time identify what is achievable if you fail to get it done within that limit.

If all this sounds like common sense, it is of course – but I found that in this instance I got too focused on a specific feature, rather than on getting the application functional enough that users can start using it sooner rather than later.


May 15, 2008

Flash Player 10 ('Astro') pre–release on Adobe Labs

Writing about web page http://labs.adobe.com/technologies/flashplayer10/

A pre-release of Flash Player 10 is now out on Adobe Labs. Astro has a number of new features; P2P support, Speex voice codec (no more having to use ASAO!), dynamic streaming support and RTMFP, 3D, improved hardware acceleration and more sophisticated text control being the ones I’m most looking forward to.

The full feature list can be found here


May 14, 2008

Flash H264: Moving the MOOV Atom

I just had to encode a couple of videos from AVI to H.264 format for playing via a Flash-based video player and noticed that the player was having to download the whole file before playing it. I checked out this Adobe Tech article on H.264 encoding and here’s why:

One important thing about playing an H.264 video file as progressive download is that the moov atom needs to be located at the beginning of the file, or else the entire file will have to be downloaded before it begins playing. The moov atom is a part of the file that holds index information for the whole file.

I was using SUPER to encode to H.264, and by default the moov atom gets placed at the file end. Fortunately, Renaun Erickson at Adobe has kindly created a small AIR application (a port of a C++ application) that will take a standard H.264 file and relocate the moov atom to the front of the file, and then progressive download works properly.

Edit- thanks to Marshall’s comment, if you’re using SUPER there’s an option to select ‘Streamable H.264’ – do that and the moov atom will be put at the beginning of the file. :-)


May 09, 2008

AS Development skills sharing at Warwick

Chris was talking today about intra-team/department skills sharing, which I think is a great idea. With regard to Flash and Flex development at Warwick we’ve recently embarked on something along these lines, with the formation of a University Flash and Flex developers group consisting of people actively using (or just interested in) Actionscript development. It started with a forum that was initially populated with ITS people (plus one or two others), but since starting to deliver some Flash courses for ITS Training I wanted to maintain contact with what attendees did with the skills they’d acquired after the course, and the forum was opened up to allow more people to contribute. We held the first ‘skills session’ a couple of weeks ago, in the Teaching Grid. It was purposely an informal gathering, consisting of developers from ITS and departments, plus lots of coffee and biscuits. The session was an opportunity for everyone to show what they’d been working on and share expertise and a mix of ongoing Flash, Flex and AIR projects were demonstrated, plus discussion on development approaches and potential applications in the future.

Overall I thought it went well (we ran out of time in the end) and although next time some structure to the session might help us cover ground more efficiently, the informality and range of projects kept it interesting, and it was especially good to share ideas with others while receiving questions and feedback. As a result of the session, I’ve been asked to present a more formal hour-long session on AIR to the CIS Team next week, which I think I’ll prepare some slides for.

Anyway, my point is that personally I found it quite fun/rewarding to find out what other people were doing or planning to do with the technology, and to see and discuss approaches/methodologies and alternatives; we should definitely do more of this kind of thing in future. Time will tell whether we maintain the Flash/Flex/AIR group sessions but I hope we can.

Warwick staff interested in Flash/Flex/AIR/AS3 development can join the developer group forum here. For students, Warwick Game Design have expertise with Flash for game development.


May 06, 2008

Flex–Spy – Live Component Inspector

Writing about web page http://code.google.com/p/fxspy/

I’ve been using Flex-Spy today for the first time, and it’s really useful. It allows you to inspect and affect pretty much any parameter of a component while the application is running which is way faster than constantly building and running the app for trying small tweaks, and saves waiting for the CSS previewer or refreshing the Design View. Installation is a snap as it’s packaged as an SWC.

View a demo of Flex Spy (press the FlexSpy button top right to launch the inspector)


January 03, 2008

I'm leaving Warwick

I don’t write here much any more, but I felt I should add one last entry…

After 3 years as a student and 7.5 years working here, I’m leaving Warwick. I’m going to work for a small IT consultancy company in Leamington Spa called Black Pepper Software. They are a great bunch of people and I’m really looking forward to starting (on Monday 14th Jan), but I’m obviously really going to miss it here after being here for so long.

My last day is next Friday (11th January), so after that this rarely read and even more rarely written blog will still be here, but will be made inactive.

Byeeeeeeeee!


July 16, 2007

My mad dog

Writing about web page http://www.youtube.com/watch?v=3ySTY7HCLXM

Took Gizmo to the woods and discovered that he likes to swim…and then go mad.

Turn up the volume to hear me swear when he almost knocks me over half way through :)


May 30, 2007

Amazing Microsoft Surface Computing

Writing about web page http://www.microsoft.com/surface/

I’ve not been inspired to blog for a while, but something has really caught my imagination over the last couple of days as it has a bunch of other people.

What’s really amazed me is the Microsoft (yes…Microsoft…) Surface Computing system.

It’s basically a flat touch sensitive computer screen, but they have implemented it so elegantly it has to be seen to be believed. The best demo I’ve seen is this one:

First Look: Microsoft Surface Computing




March 26, 2007

Java UTF–8 international character support with Tomcat and Oracle

Introduction 

I've spent the last few days looking at getting proper international character support working in our Files.Warwick application working.

At E-Lab we've never been that great at doing internationalisation support. BlogBuilder does a pretty good job of internationalisation as can be seen by quite a lot of our bloggers writing in Chinese/Korean/Japanese.

However, it's a bit of a cludge and doesn't work everywhere.

It didn't take long for someone to upload a file to Files.Warwick with an "é" in the file name. Due to our previous lack of thought in this area, this swiftly turned into a ? :(

So...how do you get your app to support international characters throughout?

What is international character support?

You'll hear all sorts of jargon regarding internationalisation support. Here is a little explanation of what it is all about.

What I do NOT mean is i18n support which is making the application support multiple languages in the interface so that you can read help pages and admin links in French or Chinese. What I mean by internationalisation support is being able to accept user input in any language or character set.

Tim Bray has a really good explanation of some of the issues surrounding ASCII/Unicode/UTF-8.

UTF-8 all the way through the stack

We need to look at UTF-8 support in the following areas:

  1. URLs
  2. Apache
  3. HTML
  4. Javascript
  5. POST data
  6. File download (Content-Disposition)
  7. JSPs
  8. Java code
  9. Tomcat
  10. Oracle
  11. File system

I'll go through each of these areas and explain how well they are supported by default and what changes you might need to make to support UTF-8 in each area.

URLs 

URLs should only contain ASCII characters. The ASCII character set is quite restrictive if you want to use Chinese characters for instance, so there is some encoding needed here. So if you've got a file with a Chinese character and you want to link to it, you need to do this:

"中.doc" ->  "%E4%B8%AD.doc"

Thankfully this can be done with a bit of Java:

java.net.URLEncoder.encode("中.doc","UTF-8");

So, whenever you need to generate something for the address bar or a direct or something like that, you must URL encode the data. You don't have to detect this as it doesn't hurt to do this for links which are just plain old ASCII as they don't get changed, as you can see with the ".doc" ending on the above example.

Apache

Generally you don't need to worry about Apache as it shouldn't be messing with your HMTL or URLs. However, if you are doing some proxying with mod_proxy then you might need to have a think about this. We use mod_proxy to do proxying from Apache through to Tomcat. If you've got encoded characters in URL that you need to convert into some query string for your underlying app then you're going to have a strange little problem.

If you have a URL coming into Apache that looks like this:

http://mydomain/%E4%B8%AD.doc and you have a mod_rewrite/proxy rule like this:

RewriteRule ^/(.*) http://mydomain:8080/filedownload/?filename=$1 [QSA,L,P]

Unfortunately the $1 is going to get mangled during the rewrite. QSA (QueryStringAppend) actually deals with these characters just fine and will send this through untouched, but when you grab a bit of the URL such as my $1 here then the characters get mangled as Apache tries to do some unescaping of its own into ISO-8859-1, but it's UTF-8 not ISO-8859-1 so it doesn't work properly. So, to keep our special characters in UTF-8, we'll escape it back again.

RewriteMap escape int:escape
RewriteRule ^/(.*) http://mydomain:8080/filedownload/?filename=${escape:$1} [QSA,L,P]

Take a look at your rewrite logs to see if this is working.

HTML 

HTML support for UTF-8 is good, you just need to make sure you set the character encoding properly on your pages. This should be as simple as bit of code in the HEAD of your page:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 

You should be able to write out UTF-8 characters for real into the page without any special encoding. 

Javascript 

Javascript supports UTF-8 characters very well so as long as you don't use escape() then when your users enter characters, they shouldn't get mangled. We also use AJAX do do some functions in our application so you need to think about that as well but again, it should just work.

All of the above only holds true if you set the character encoding right on your surrounding HTML.

POST data

Getting POST datafrom the user in the right format is simple too. As long as your HTML has the right encoding then you should be ok.

File download (Content-Disposition) 

If you want to serve files for download from your app, as we obviously do with Files.Warwick then you'll need to understand how browsers deal with non ASCII characters in file names when downloading. Unfortunately the standard is not exactly well defined as no one really thought about UTF-8 file names until recently.

Internet Explorer supports URL encoded file names but Firefox supports a rather strange Base64 encoded value for high byte file names, so something like this should do the job:


String userAgent = request.getHeader("User-Agent");
String encodedFileName = null;

if (userAgent.contains("MSIE") || userAgent.contains("Opera")) {
encodedFileName = URLEncoder.encode(node.getName(), "UTF-8");
} else {
encodedFileName = "=?UTF-8?B?" + new String(Base64.encodeBase64(node.getName().getBytes("UTF-8")), "UTF-8") + "?=";
}

response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedFileName + "\"");

Obviously you can tweak the user agent detection to be a bit smarter than this. 

JSPs 

UTF-8 support in JSPs is pretty much a one liner.

<%@ page language="java" pageEncoding="utf-8" contentType="text/html;charset=utf-8" %>

Include that at the top of every single JSP perhaps in a prelude.jsp file and you're away. 

Java code

As long as you source strings are properly encoded then generally you can rely on Java to keep your UTF-8 encoded input. However, be careful what String functions you perform on your UTF-8 data. Be sure to do things like this:

myStr.getBytes("UTF-8") rather than just myStr.getBytes()

If you don't then you'll most likely end up with ISO-8859-1 bytes instead. If for some reason you can not get your input data to be UTF-8, and it is coming in with a different encoding, you could do something like this to convert it to UTF-8:

String myUTF8 = new String(my8859.getBytes("ISO-8859-1"),"UTF-8")

Debugging can be fun with high byte characters as generally logging to a console isn't going to show you the characters you are expecting. If you did this:

System.out.println(new String(new byte[] { -28, -72, -83},"UTF-8")

Then you'd probably just see a ? rather than the Chinese character that it really should be. However, you can make log4j log UTF-8 messages. Just add 

<param name="Encoding" value="UTF-8"/>

To the appender in your log4j.xml config. Or this:

log4j.appender.myappender.Encoding=UTF-8

To your log4j.properties file. You might still only see the UTF-8 data properly if you view the log file in an editor/viewer that can view UTF-8 data (Windows notepad is ok for instance).

Tomcat

By default Tomcat will encode everything in ISO-8859-1. You can in theory override this by setting the incoming encoding of the HttpServletRequest to be UTF-8, but once some of the request is read, then the encoding is set, so chances are you might not be able to manually do:

request.setCharacterEncoding("UTF-8")

early enough to have an effect. So instead you can tell Tomcat you want it to run in UTF-8 mode by default. Just add the following to the Connector you want UTF-8 on in your server.xml config file in Tomcat.

URIEncoding="UTF-8"

Not doing this has the fun quirk that if you have a request like this:

/test.htm?highByte=%E4%B8%AD

If you did request.getQueryString() you'd get the raw String that "highByte=%E4%B8%AD", but if you did request.getParameter("highByte") then you'd get the ISO-8859-1 encoded value instead which would not be right. Sigh.

Oracle

You could just URL encode all of your data and put it into the database in ASCII like you always used to. However, that doesn't make for very readable data. There are two options here although I've only tried the one.

  1. Set the default character encoding of your Oracle database to be UTF-8. However, it is set on a per server basis, not a per schema basis so your whole server would be affected.
  2. Use NVARCHAR2 fields instead of VARCHAR2 fields and you can store real UTF-8 data.

We went for option 2 as we have a shared Oracle server. First of all, convert all fields that you want to store UTF-8 data in from VARCHAR2s to NVARCHAR2s. Be careful as I don't think you can change back!

You then need to tell your JDBC code somehow that it needs to send data that the NVARCHAR2 fields can undertand. There are a couple of ways of doing this too:

  1. Set the defaultNChar property on the connection to true.
  2. Use the setFormOfUse() method that is an Oracle specific extension to the PrepearedStatement

I went for option 1 as the problem with option 2 is that you have to somehow get at the Oracle specific connection or prepared statement within your Java code. This is not fun as you'll often be using a connection pool that will hide away these details.

Files system 

File system support of UTF-8 characters is again pretty good, but you are sometimes going to have issues with viewing the file listings. I just couldn't get a UTF-8 file name to display properly over a putty SSH connection. Through a simple Java test program, I could write and read back a UTF-8 file name on our Solaris 10 box, but all I could ever actually read when doing an "ls" was ?????.doc. So for the sake of maintainability of the file system I went for a URL encoded version of the file. This isn't ideal, but it works.

Conclusion

As you can see, there is quite a lot of work involved in supporting UTF-8 throughout. A lot of my time was spent researching as my understanding of encoding issues wasn't great. Now that I've put together this guide, I hope all of our apps can start to work towards full UTF-8 support.

Of course the above guide is quite specific to my experience in the app I was dealing with and the environment I work in so your experiences might be more or less painful :) 


December 15, 2006

New car!

After owning my Audi A4 for 3.5 years, it was time for a change. With the arrival of Dog #2 it was a bit of a squeeze in the back of Steph’s Polo for the two of them, so I needed a car with a bigger boot.

After just 4 days on Autotrader, my Audi was gone…a sad day indeed. But just a few days later and I’ve got my replacement. I would have liked an Audi A3 Sportback or even the Volvo V50, but I just can’t justify it really so I went for a top of the line (except the ST as I really don’t want a 20mpg, group 20 insurance car) year and a half old Focus…which works out a hell of a lot cheaper than the A3 of V50 (unsurprisingly).

Focus

So far I’m really happy with it, it drives surprisingly well, the 2.0 turbo diesel really flies and it handles brilliantly. I must admit that I do miss the refinement of the Audi, but I don’t think I’ll miss it in the long run. Now I just have to see if I can get the dogs in the back!


November 24, 2006

Files project update

Follow-up to Spring and Hypersonic/Hibernate tests from Kieran's blog

It’s been a while since my last update on this project. Unfortuately we’ve not done as much as I would have liked. Both Sarah and I have had holiday and we’ve been busy on other projects.

We’re back in the swing of things now and we’re moving forward a lot quicker now that most of the underlying infrastructure is in place.

To give an idea of the size of the project already (as well as just numbers can tell you anything):

  • 75 classes and interfaces
  • 22 test classes with 50 tests
  • 15 hibernate mapping files
  • 5 database tables (we are mapping quite a few classes to a single table in quite a few places)
  • 14 jsps (not many as we’ve not got loads of interfaces to some of the underlying code yet)

So, what does this code do then?

We’ve recently added quotas and the ability to email a file to someone. This basically sends an email with a link in it to a unique download URL that lasts a week and lets the person who sent the file keep track of downloads of that file (they get notified by email when it downloads and can see the download count on an web interface within their account).

We’ve also got the permissions system in now so that you can give view/edit/admin permissions to a person or a group of people (as usual there is no interface for this yet…just the code).

Everything is still pretty ugly as we’ve not done any graphic design work, so I’m not going to post any screenshots!


November 13, 2006

Gizmo's first 36 hours

Follow-up to Yet another new member of the family…Zeno/Gizmo from Kieran's blog

We’ve had Gizmo now for almost 36 hours and he’s been absolutely fantastic.

Gizmo in his bed Gizmo in the garden
Maggie and Gizmo in the garden Me and Gizmo

Even though he did pee in the house a few times yesterday and first thing this morning, he is a lot better now and is getting the right idea now and has been good all day.

I spent the day at home and kept an eye on him and Maggie. As expected, Maggie is not yet his biggest fan and has growled at him quite a lot. However, they’ve not actually had a fight and don’t look like they will. I even managed to leave them both alone at home for an hour today and they were fine…I got a great double bouncy greeting when I got home :)

Gizmo is also really responsive to training already and is already being really obedient, he’ll be all trained up and into his routine in no time.

All in all Steph and I are really pleased with him and couldn’t have picked a nicer dog!


November 10, 2006

Trying to get hold of people

Writing about web page http://www.dilbert.com/


November 08, 2006

DropSend for sale

Writing about web page http://www.barenakedapp.com/dropsend/dropsend-monthly-profit

Carson systems are selling DropSend so that they can concentrate on their new Amigo project. What makes this interesting is that they are doing their usual openness during the sale and are posting what would usually be regarded as trade secrets on their blog:


How much profit does DropSend bring in each month?
  • Revenue: $9,041.81 per month (and growing by 8.6% per month)
  • Costs: $2,100 per month (Servers at 365main.com + maintenance)
  • Profit: $6,941.81 per month

Looks like a lot of people have this sending/storing large files problem.


November 05, 2006

Yet another new member of the family…Zeno/Gizmo

Follow-up to New member of the family from Kieran's blog

After having a dog for almost 2 years…it’s time for another one!

We’ve had Maggie for almost 2 years now (2 years in January) and we’ve occasionally been thinking it’d be nice to have another dog, but we’ve never been that serious about it.

After going on holiday to visit my parents and yet again seeing Gina and Tiro and what good mates they are and seeing how well Maggie had got on with Steph’s Dad’s dog whilst we were away, it made us think again about another dog. This time, it seems right so we went and had a look around the Dogs Trust the last two weeks and yesterday we found the one :)

He’s currently called Zeno and was rescued as a stray from Ireland. He’s a Black Lab cross of some kind (possibly Border Collie) and about a year old. He’s a really nice boy, very friendly and seems to get on really well with Maggie when we took her to meet him both yesterday and today. We’re going to change his name to Gizmo as Zeno is just a made up kennel name and he doesn’t respond to it at all. With a bit of luck we’ll pick him up next Sunday!

It’s going to be hard work having a second dog, but I think it’s going to be really good for us as well as really good company for Maggie.

Maggie
Maggie close up

Best friends, Gina and Tiro
South Africa 2006 32

Zeno/Gizmo
Zeno/Gizmo and Maggie Zeno/Gizmo Zeno/Gizmo, me and Maggie Zeno/Gizmo


November 01, 2006

Spring and Hypersonic/Hibernate tests

Follow-up to Files project dev server from Kieran's blog

Having been away on holiday for 2 weeks and having quite a bit of catching up to do with other stuff, we’ve not made huge leaps in the last few weeks. However, we’re building up steam again now and have finally sorted out after a few restarts the domain model we’re going to be going for around the key aspects of accounts, files, folders, etc…

Up until now for speed of prototyping, we’ve been working with Spring, but not yet involved a database as we can quite easily just talk directly to the file system for now. However, now is the time to start getting more complex and we need somewhere to store all the metadata of all kinds about the files and accounts.

As usual, we’ll try and incrementally do the Hibernate mappings and start to build the database scheme. To do this quickly we’ll be building against some tests and a hypersonic database to start with. Spring provides the handy “AbstractTransactionalDataSourceSpringContextTests” class which allow easy binding of Spring objects and also a simple way to plug in transactional capabilities to your tests.

By coupling these test with the Hypersonic database which can be built and torn down in memory in just milliseconds, we can prototype the database very quickly.

Hibernate session-factory config

<session-factory>
        <property name="dialect">org.hibernate.dialect.HSQLDialect</property>
         <property name="use_outer_join">true</property>
        <property name="hbm2ddl.auto">create-drop</property>

        <mapping resource="......hbm.xml"/>
   </session-factory>

Spring sessionfactory and datasource


<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="configLocation"><value>hypersonic-hibernate.cfg.xml</value></property>
        <property name="dataSource" ref="dataSource"/>
    </bean>

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName">
          <value>org.hsqldb.jdbcDriver</value>
        </property>
        <property name="url">
          <value>jdbc:hsqldb:.</value>
         </property>
        <property name="username">
          <value>sa</value>
        </property>
        <property name="password">
          <value></value>
        </property>
    </bean>

So based on your mappings files, the database schema gets created in a new hypersonic database for each test giving you a working and clear schema to test against. Magic.


public class HypersonicTests extends AbstractTransactionalDataSourceSpringContextTests {

    protected String[] getConfigLocations() {
        return new String[] { "file:apps/webinterface/src/applicationContext.xml","file:apps/webinterface/test-src/hypersonic-db-context.xml"};
    }

}

public class DbConnectionTests extends HypersonicTests {

    private SessionFactory _sessionFactory;

    public final void testDbConnection() throws Exception {

        Session session = getSessionFactory().openSession();

        session.save(new AccountImpl(null, null, "Test", null));

        session.flush();

        List accounts = session.createCriteria(Account.class).list();

        assertEquals(1, accounts.size());

    }

    public SessionFactory getSessionFactory() {
        return _sessionFactory;
    }

    public void setSessionFactory(final SessionFactory sessionFactory) {
        _sessionFactory = sessionFactory;
    }

}

October 27, 2006

Back from South Africa

Follow-up to Off to South Africa from Kieran's blog

So, we got back from South Africa on Sunday afternoon. I’ve only just got around to uploading photos today, as I’ve been either too busy or too tired since then to do it.

South Africa 2006 gallery

I’m not going to write reams as the photos will tell the story…to sum up though:

  • Long but entertaining flights with Emirates…superb entertainment systems!
  • Great weather (mid 20s to 30C most of the time)
  • Free accommodation at my parents’s lovely house
  • Great food as the South Africans really know how to do good meat :)
  • Cheap, exchange rate is great at the moment (about R14 = £1)
  • Lots of time spent with the whole family who we don’t see often enough really now-a-days
  • A fantastic safari in Hluhluwe, staying at the great but wild Munyawaneni lodge

I was really pleased with my new camera as it helped me take much much better photos than I did last year. All of the pictures below and shrunk for upload, but otherwise unedited. I was particularly pleased with the zoom and low light performance of the camera as I wouldn’t have got half my shots on safari otherwise. I’ve only highlighted a few here, there are more in the gallery and a lot more (about 500) on my computer.

In Southbroom at my parents’s place

The view

Watching whales from the house

Tiro and Gina

South Africa 2006 13

Flying Tiro!

Vervet Monkey in the back garden

Me on a jetski!

Visting uSharka marine park

Dolphins

Steph and a shark

Turtle feeding time

On safari!

Croc and water monitor

Zebra running down the road

Elephants crossing

Rhino crossing

A lion pride stalking some rhino

Giraffe

My brother the bird spotter! :)

Game in the camp!

Being watched by lions

Zebra and birds

Hippo

Hyena

Goodbye


October 06, 2006

Off to South Africa

Well, in two hours time Steph and I will be in Birmingham Airport checking in on our first long flight to South Africa (via Dubai).

We’re gone for just over two weeks and will be staying with my parents in Southbroom, near Durban. I’ll be taking a load of pictures with my new camera, so I’ll upload those when I get back (if they’re any good).

It’s spring right now in South Africa so the weather’s going to be pretty mixed, some rain, but hopefully around 28oC.

Right, better go finish packing!


October 05, 2006

Files project dev server

Follow-up to Getting a project up and running from Kieran's blog

One of the important things to try and get ready as early as possible is a test/pre-production system that is fairly close to what you expect your live environment to be. This is so that you don’t spend the whole time developing on a single JBoss instance on a single processor Windows box with local storage and then deploy on a multi-processor, multi-JBoss and remote storage box and discover that nothing works!

We are now starting to run Solaris 10 which gives us the great Zones feature. Our sys admins have setup a zone on one of our new boxes that is a test/pre-prod environment for the files project. We’ll run something like this:

  • Single Apache 1.3x instance with HAProxy to load balance between the JBoss instances
  • Two JBoss instances both running live rather than a live and a standby
  • For now local storage, but eventually we’ll use our NetApp

The twin live JBoss instances means that our application will have to be completely stateless. This is a good thing for scalability, but it makes multi-step processes within the application a bit harder as we won’t have a session to store data in. This is usually not a problem for simple applications, but working on something like a mutli-step zip upload could be tricky.

The other advantage of having a test instance up and running is that you can start to point very early test users at it (rather than a local instance on your own machine). This gets you some good early feedback/ideas/bug-spotting.


October 02, 2006

New toy: Canon S3 IS

Writing about web page http://www.canon.co.uk/For_Home/Product_Finder/Cameras/Digital_Camera/PowerShot/PowerShot_S3_IS/

It’s my birthday in just over a month, but I’ve got my main present early this year :)

As we are off on holiday to visit my parents in South Africa in a few days time, Steph bought me the Canon S3 IS (bargin at £250 from Pixmania) to replace my aging Canon A40. I’ve not had much of a chance to play with it yet, but I’ll have loads of time on holiday. Only problem around the house is that poor Maggie is afraid of it :( I think there must be some high frequency sounds coming from it when the lense extends as she goes all pathetic whenver I turn the camera on (even if she can’t see it happening), poor thing.

The A40 went with me last year to South Africa on safari. It was ok, but I was very jealous of my Dad’s more up to date camera. So with this in mind, I decided it was time for an update. As DP Review puts it:

The PowerShot S3 IS features:

  • 12x optical zoom lens with USM and UD lens element
  • Optical Image Stabilizer
  • 6.0 Megapixel CCD
  • Larger size 2.0 Vari-angle LCD
  • 30fps VGA movies with stereo sound and Photo in Movie feature
  • DIGIC II, iSAPS and Flexizone AF/AE for fast, precise results and 2.3 fps continuous shooting performance
  • 20 shooting modes and My Colors photo effects
  • High ISO Auto and ISO 800 for low light flexibility
  • Widescreen (16:9) recording

Hopefully I can compete for the best photos this time around…at least I can’t blame the tools this time.