Flex Source to the Rescue

Developing in Flex can be very frustrating at times. Latest hangup was due to mx.controls.Text class scrolling content undesirably when mouse wheel is turned. None of the solutions I found online worked but as I started writing my own custom text component, I remembered that Flex came with source code many of the framework classes. So I dove in and found this hidden yet relevant documentation in the source code:

If the Text component has an explicit width, its text wordwraps within that width, and the measured height is tall enough to display all the text. (If there is an explicit height or a percent height in this case, the text may get clipped.)

If it doesn't have an explicit height, the measured height is tall enough to display all the text.

If there is an explicit height or a percent height, the text may get clipped.

With this info, all I had to do was set width explicitly and leave height unspecified to prevent Text component from scrolling.
The lesson here is that, while Adobe provides a lot of documentation, real gems are in the source code.

Akismet is Alright

Duncan Riley at TechCrunch writes:

Akismet is a service that relies on the failure of the WordPress code to be able to natively deal with comment spam. The service is free for personal use and a paid service for everyone else. As the co-founder and essentially the head of the WordPress open source movement, Mullenweg leads the initiatives by WordPress to combat comment spam. On the other hand as the head of Automattic he runs a company that profits from those very failings. The question then becomes: can one profit from the failings of an open source product whilst still leading that very code’s development?

Wrong. The problem Akismet addresses is a general problem, not one specific to WordPress and it would be less effective for every blog hosting services to run their own comment filtering service. IMHO, fees Akismet charge are well-earned and kudos Akismet receive, for offering free comment filtering service to non-commercial bloggers, is well-deserved.

As to whether there is an acceptable line for advertising and conflicts of interest, my answer is yes but does it really matter when the line can be redrawn?

Trying Bon Echo

I've been getting tired of Firefox hanging frequently on my Mac but couldn't switch to alternatives like Camino because, as a developer, I need a browser with widest third-party support (like Silverlight plug-in). So when I ran across a comment suggesting Bon Echo as a possible solution to a similar problem Fred Wilson was suffering from, I decided to give it  a try.
This post is intended to help people find Bon Echo because googling turned up only old versions. You should be aware that:

  1. Bon Echo is a build of Firefox supposedly optimized for OS X.
  2. Bon Echo versions are slightly behind that of main Firefox versions (latest Bon Echo version is 2.0.0.5 while the latest Firefox is 2.0.0.6).

First point is essential to me because I can use existing Firefox configuration as-is. You will have to delete Firefox.app though. Hopefully, the second point will be resolved when Bon Echo becomes more popular.

Stretching TwitterGram

So a limping version of my TwitterGram Facebook app is up and running now but I still have a list of chores to finish, including an updater (it's manual update til then), before I can think about cooler features like:

  • conversation – many people posting TwitterGrams on one topic.
  • linker – show links and text while playing one or more twittergrams.
  • player – play a conversation together, auto-leveling volume as it plays.

A cheap way of doing conversation is just looking for TwitterGrams with same title. I can then list them in an OPML file so they can be played together. A custom Flash-based player is also needed to display links while playing so I can say "checkout blah" without having to spellout a URL. I think John Batelle was going to ask HP if they can do that for his voice-casts.

Flash-based player running on mobiles could make the listening experience more enjoyable and hands-free. Hmm. Maybe it makes more sense to just call-in to listen to TwitterGrams. Then VoiceXML-based player is all that's needed. VoiceXML works is needs to be done anyway to record TwitterGrams. I wonder if there is a simple way to 'capture' links with a single button click while listening to a phone call, sort of like 'catching' song info or product info while listening to radio or watching TV.

Anyhow, I am going to have to wrap up all this fast before I get too distracted away from my other projects. ;-p 

Hibernate and TopLink

I've had a lot of trouble using TopLink with Tomcat. Most of the problems appeared to be related to foreign keys and reverse-engineering but, looking deeper, were caused by 'weavers' and classloading. TopLink intercepts calls to POJOs by generating dynamic proxy code then weave them by playing switcheroo at classloader level. This technique apparently has some conflicts with Tomcat's own way of loading classes, conflicts that I spent many hours chasing and resolving only to face more later before giving up. I haven't used OpenJPA but I've read elsewhere that it's even worse. I am sure they'll improve but, for now, stay way.

After giving up on TopLink, I tried Hibernate 3.3 and, despite a lot of initial head scratching, I am happy to report that it worked well without even a single problem. Hibernate's two downsides are that it needs a lot of third-party jars to get it working and that it's rather slow. But then I couldn't go far enough along with TopLink to even test performance so the downsides are bearable. I can always rewrite the DAO layer later using iBATIS or use JDBC directly. For now, ease of development matters the most.

JPA Rough Spots

While JPA is nice, here are some possible rough spots:
TOPLINK-60
Some foreign key columns will confuse TopLink JPA provider off in LAZY fetch mode, causing TOPLINK-60 exception that complains mysteriously about a missing method. Apparently the cause is related to some complicted 'weaving' logic. Quick fix is to switch to EAGER for the offending column (use missing getter method name as hint) and deal with consequences later.
Uncommitted Persist
Persisted but not yet committed POJO instances don't really exist which could lead to problems when you reference them from other POJO instances. Fix is to fiddle with CascadeType settings. For example, if A and B are both new instances and A.b references B, then make sure A.b cascade type is set appropriately (i.e. CascadeType.ALL) then just persist A. Since A.b is set to cascade, persisting A will cause B to be inserted first then its surrogate primary key will be used to insert A. If A and B has a OneToMany relatiohship then you would use A.getB().add(b) instead of A.setB(b).
Frankly, I don't like all this behind-the-scene cascading business so I try to avoid using it whenever I can. But it's difficult to avoid during inserts as the only alternative I can see is  brute-forcing commit and fetch at each step and deal with rollback manually.

OPML and Namespace

Dave Winer asks XML experts: can we put a namespace declaration at the head of an OPML file without breaking processors? If breakage of not even a single existing OPML app is acceptable, then the question can't be answered without actually counting the number of apps that breaks. But this can't be done because not everyone is paying attention.
My best informed guess is that this change will break some apps. A downside of simplicity in XML-based data format is that simplicity could mislead developers into doing task-specific hand-parsing instead of using fully compliant XML parsers.
I think it's more relevant to ask whether his immediate need requires namespace support. Looking at his proposed change (add ownerId element in the head section), I think just adding the element as-is will break fewer OPML apps than doing it the standard way using XML namespace.
Standards are useful but not when it hurts more than helps.

Bruce Schneier on Scanbone Culture

In response to news of pirated copies of the last Harry Potter book appearing on BitTorrent, Bruce Schneier wrote:

Anyone fan-crazed enough to read digital photographs of the pages a few days before the real copy comes out is also someone who is going to buy a real copy. And anyone who will read the digital photographs instead of the real book would have borrowed a copy from a friend. My guess is that the publishers will lose zero sales, and that the pre-release will simply increase the press frenzy.

Sounds reasonable but reasons tend to crumble before adaptive ways of life and culture. Already, Asia has developed a sizable culture of photocopied books shared online. In Korea, photocopied books are called 스켄본 (Scanbone) and they have gone beyond BitTorrent and into private storage services. And it's irreleveant whether they are fans or not because shortcuts can easily become a way of life.

wdgtbldr

Peter Yared, ex CEO of ActiveGrid, came by my house today. We sat outside (great weather today) and talked about our common past, (NetDynamics) and common near term focus. We took turn demoing our stuff and talked about ways to help each other. I think he has a potential winner with wdgtbldr, his new venture for which he already got a decent seed funding lined up, if he executes right. I am funding my own but I think Other People's Money could add the right kind of motivation and urgency I need to execute.
As to what his startup is about, it's ugly name speaks for itself. ;-p 

Chording Keyboard for iPhone and Mac?

I've read that iPhone's virtual keyboard is not as bad as initially thought but I wonder if Apple will implement virtual version of Engelbart's 5-key chorded keyboard using multi-touch. If done right, users could just tap on the phone's glass surface with five fingers to type (fingers will have to be closer to each other due to lack of space but I don't see a major problem). I thought about hacking together a web-version but, according to iPhone developer docs, iPhone browser doesn't deliver multi-touch events to webapps.
For Macs, I think multi-touch mouse which Apple recently filed patent for might be used.