Man, Does Time Fly

In the last 2 years my partners and I have worked on and tried to sell a product we built at a our previous company. This product has been in development for 5 years (it’s been in production for 3 years). In those 5 years Java and it’s tools have matured greatly. If we had to build it (or a project of it’s size) from scratch today, it would probably only take 9 months and most of that would focus on the data model. I’ve personally learned a lot about software development in the last five years. But the last 18 months has been about selling. Our conclusion: selling software is hard, and selling enterprise software is nearly impossible. That’s why for the last 3 months we’ve been focusing on consulting.

Consulting is nothing new for us; we’ve done it in the past, and given our results, we’ll certainly continue doing it. I’ve more or less finished a prototype of a medium sized website with a lot of complex features built in PHP, IT mandates that the finished site be built in dot-NET (Doubt I’ll be involved in that). I’ve got a few upcoming sites that are going to be PHP based. I’m working on a Ruby-on-Rails based site. I’ve tinkered with NASA’s World Wind Java SDK for a part of project. And I developed a prototype application for the PepperPad 3. Oh, and we’ve load tested, and did code reviews for a few applications we didn’t write (much better than being on the receiving end).

In other words it’s been a busy few months.

Why Consulting? or Web Start is Killing Us

Our product is built in Java, it’s a three-tier, rich-client, Web Start distributed enterprise system for insurance companies. If you can believe the articles at JavaDesktop this sorta thing has been coming into vogue has the last few months. We when started this thing five years ago, no-one was doing Web Start enterprise clients. I still don’t think that many people are doing them.

Guess what, Web Start rich-clients are hard to sell. Maybe it’s just in the insurance industry, which people always say is 20 years behind the technology curve, we have to spend a lot of time convincing people that our product isn’t client-server. We tell them you can run it from anywhere. We patiently explain to IT that there aren’t any upgrade headaches, everyone is always on the latest version just like a web-app. We tell them that our software can do more (and in more productive ways) than most web-apps, but AJAX is making that less true. Most customers don’t care that maintaining one code path for Java means more solid software that doesn’t depend on the whims of browser vendors. Basically, you spend a lot of time/energy selling web-start just to have people go “Yeah, I don’t know. It looks client-server.”

Occasionally, you’ll come across refugees from web-apps. They love you because you’re transmitting only the data (mostly) over the wire in a binary format instead of bloated plain-text with markup. They love the power of rich-clients. They know that running mission critical applications as a script in the same in same program you use to access every other service is begging for security exploits or other headaches. They know HTML wasn’t made for applications. Then they get overruled by someone higher in the corporate structure.

So now, we’re focusing on consulting, that means I don’t play with Swing as much these days. Sure, World Wind uses some Swing (but mostly JOGL). The Pepper Pad doesn’t use much Swing but it can. But mostly we’ve using web technologies. They work well enough for “casual use” applications. What’s “casual use” for some people, is mission critical for others. That said, I still think adobe is crazy for working on a web version of Photoshop.

Anyway, on to silly comments about server software only the most bored geeks would read.

PHP

I really like PHP. Sure, PHP has got it’s issues and quirks, but when you don’t want to be limited by a framework and you need it done quick PHP is the way to go. The biggest benefit of PHP is that no matter what sort of hosting solution you have, it has a 99% chance of supporting PHP. If you’re using Java, dot-NET, or even Rails, your hosting options are more limited. Yes, if app/site gets very popular you will need dedicated or co-located hosting. But, when you are small, a shared-hosting plan can serve you just as well, in most cases, while you are still feeling out your audience and working on your offering.

Ruby on Rails

I have a love/hate relationship with Rails. Once you commit to learning the framework, Rails is a joy to use. Ruby is a great language. The hate comes when you deploy your app. Rails isn’t fast and if you deploy to shared-hosting, even a “dedicated” box that serves a few other sites using other server software, then Rails can’t have it optimal configuration. I hope Ruby get faster at launch time and at runtime and that Rails gets faster and easier to deploy (webserver/Rails integration) because I’d REALLY like to use them more. Just to clarify: it’s the setup of a production environment that I don’t like. Once the environment is setup, actual deployment is pretty painless. Except, sometimes your production environment doesn’t automatically pull in the same modules as your development environment. While some shared-hosting providers allow Rails hosting, it’s not really fast enough to do more than providing clients with a sneak preview during development.

.NET (aka dot-NET)

Um, yeah, dot-NET. My experience thus far with dot-NET is from the outside looking in. I helped on a code and security review of a dot-NET project. We also did load testing and polish on a dot-NET project. I found and fixed a bug in dot-NET project after the developer gave up searching. I had always assumed that dot-NET was more of a application framework, but apparently not. One of the projects used a third-party Object-Relational Bridge and the others passed raw SQL statements to the database (like with PHP). It appears that dot-NET generates javascript for you, but this causes more issues (like postbacks) that don’t exist in other frameworks. In general, it seems dot-NET doesn’t do you any favors and tends to get in the way and cause problems. In other words: dot-NET is platform/framework made by Microsoft, the same company who brought you MFC. Like I said earlier, I have limited experience with dot-NET, so take my comments with a grain of salt.

In case you are wondering how I can do code reviews and security reviews in a language/platform I don’t use: It’s simple. Most web-apps have a similar structure, they have mostly the same issues and limitations, and they use the same protocols regardless of language and platform. If you take unfiltered user input and slap it in a SQL statement or on a web page, you will have security issues. Logic works the same way in most languages, it is only the syntax that changes. Understanding control flow and edge cases is far more important for reviews and debugging than knowing the language inside and out.

Server Side Java

As consultants, we haven’t had much call for server-side Java yet. I think, it’s because mostly Java is used in IT shops for much larger projects/teams than we’ve been getting. Start-ups and small companies prefer PHP, Rails, or something else. Java isn’t sexy anymore but it’s still very functional and delivers good resource utilization on the server. It’s all about using the right tool for the job. IT departments tend have the “I have a hammer, everything is a nail” mentality — so if they have Java programmers, everything is Java; if they have dot-NET people, everything is dot-NET. I still think Java is the best solution for a large project but it would be hard to recommend for medium or small sized projects.

Feb. Update

I need to post more often, sorry. I’ve been doing more Java development lately, actually mostly research because we may be rewriting some projects.

Binding

I’ve been looking into various Swing binding projects. There seem to be two big ones SwingLabs Bindings and JGoodies Binding. The SwingLabs project dropped off the list rather quickly because it is tied to the swingX components (which requires more setup in GUI builders) and it tries to do long-term persistence (we will use EJB3/Hibernate for that). Also there is no stable release at the current time (Feb 2006).

JGoodies Bindings however has had a few stable releases, a relatively small set of classes/intefaces to learn, and inspired by small-talk — These are all good things (at least to me). The major downside seems to be writing boilerplate code to glue the components to POJOs.

I don’t know, maybe the swingX components would allow us to write the code that glues the component’s data to the POJO with the GUI editor. Maybe we could automate the JGoodies code in some way. At this point, I haven’t used either tool.

WebStart EJB Clients

Have you ever written a WebStart EJB Client? No? After searching around the web, it appears not many people have. Using Web Services for our purposes is too slow and Web Services still has around 5MB overhead in client jars. Standalone EJB client jars weight in around 9-22MB depending on vendor. You also need upwards of 5 ports open. In the past, we took the hugh download size. Used VPNs when outside the local network to resolve the port problem. But now, we are looking for a better way.

That better way seems to be by avoiding the whole problem to begin with by using sevlets as front-end to your EJBs. Bright Side Remoting is an open source project I found yesterday. It seems to the answer to my problems. It has a small client jar and servlet and using the remote interfaces for your EJBs with dynamic proxies it uploads serialized data to the servlet and interacts with your EJBs. Again, this is a package I’m researching; I haven’t actually used it yet. There are a few wrinkles here, the demo doesn’t work. If click the “Home” link, you’ll see a message stating the company is no longer in business. The good news if the code is still available and under a BSD license.

FlexDock: Views Tutorial

I have been writing a little project using FlexDock and thought I’d do a write-up. R.J. Lorimer’s tutorial on FlexDock is a good starting place, if you haven’t read it, you may want to read it before trying this. Most of the examples you’ll find create all the dockables and place them on the screen in a very static way. FlexDock offers a way to persist layouts between sessions; which will be needed if you plan to take your application beyond the demo stage. FlexDock has a very nice user’s guide, but the advanced features (views, perspectives, persistance, and themes) aren’t documented yet.

FlexDock Demo screen shot. Click  for larger image.
Download Demo Source Code (Zip file).

(Continued)

Mustang Tabs

Most of the features added to Mustang I’ve felt non-committal on. But at last they are addressing a pet peeve of mine, the JTabbedPane. Read Alexander Potochkin’s post TabComponents in action. It’s stuff like this that make me wish swing’s release cycle was not tied to the JVM.

Action Groups

I’ve been implementing a reusable toolbar manager and needed a way to support toggle buttons. I implemented a (bad) temporary solution and then R.J. Lorimer publishes Swing: Comingling Toggle Buttons and Actions on Java Lobby. Great timing.

Apple’s broken ImageIO PNGs

When Apple updated their version of Java a few weeks ago they broke PNG loading in ImageIO. The PNG loaded via the Toolkit methods (and ImageIcon) still work fine. Since I had read that all updates to image formats would happen in ImageIO, I naturally use ImageIO to load all my non-icon graphics. Now, ImageIO is broken and I’ve written a couple of games the use PNGs almost exclusively. I wonder if the problem is related to endian differences between PowerPC and Intel and maybe they slipped some Intel code into the JVM.

Experiences with Matisee

The honeymoon is over. Here are a few observations about Matisee.

Header image

The first panel was a sort of header on sidebar (see above). The layout actually worked fine on my development machine, but when I tried it under Windows the header was too large. Free Design/Matisee probably wasn’t made with the use case in mind. But it works great with forms.

Mac-style About BoxThe second panel is a Mac-style about box (see left; click to see larger image). When I tried to emulate this, I noticed free design does not have a way to align to the center of components. But wait, it does not need to (for this example anyway). Anchor the sides of all the labels to the edges of the panel and set the label’s horizontal alignment to center. It then works the way I want. Hmm, sometimes researching a blog entry helps my code.

Incidentally, it seems the Java HTMLKit doesn’t like meta tags. The first line of the body would never take on the correct font or boldness with the meta tags in the HTML.

I was going to put a third dialog here. But it turns out, that Matisee was not the problem. I had an options dialog that I converted from GridBag by pullling it apart and then adding a brand new check box. The new check box would not align correctly. After some work, I found the problem was all the old components had insets and the new check box did not. The problem I was going to write about here was that even after fixing the insets, the check box wasn’t aligned on Windows, but was on OS X. In doing research for this post, I looked at the “.form” file and found the problem. When searching for inset problem, I gave the check box an empty border while the rest had the default border. So it was my fault after all.

Giving JTree Fitts

Swing ignores most human-computer interaction theories. A case is point is JTree (or even JList) and Fitts’ law. If you have programmed rich clients in Java, you’ve probably run across the annoying fact that putting an empty string in JTree or JList makes that item hard, if not impossible, to select.
(Continued)

Tiger Trees

Or maybe I should call this “Unified Dark Trees” if you’ve read John Gruber’s The iTunes 5 Announcement From the Perspective of an Anthropomorphized Brushed Metal User Interface Theme (warning: foul language). Anywho, in a previous post, I was creating an iTunes 5 like interface for an application I’m writing. This post is about the tree control. In the last post, we fixed the colors. In this post we override BasicTreeUI to paint the entire row with selection. Below is a screenshot with Swing Ocean as the backing LAF.

Screenshot

(Continued)

Tiger Style

The screenshot below is from the application I was talking about in my last post. I got bored fighting with StyledDocument and worked on the overall look of the app. Its not a complete emulation of Mac OS Tiger’s LAF by any stretch of the imagination, but I like the way it looks and I intend to make it better. This is a work in progress.

Project screenshot

First, don’t get the wrong idea. I’m not implementing this as a look and feel. It’s just a couple of custom UI classes and overriding some default properties. The point of this is to make an attractive application whose interface is patterned after iTunes 5.0. This is first application I’ve built in long time using NetBean’s Visual Builder (the 4.1 builder, not Matisse).

I put MattBorders on a few of the controls. I’ve never really used MattBorder (or many custom borders at all) before, but in playing around with NetBean’s GUI Editor I found that MattBorder does mostly what I need for this interface. Lets take the tree, splitter, and text pane as an example. First set the divider size to 1 on the splitter. Now, if we had used LineBorder on the tree’s scrollpane, we would have too many lines. With MattBorder you can pass in an Insets to control which sides get a border (a black 1 pixel border in our case). This style also does not put a border on the edges that go up to the edge of the window. Note: The divider still has a dot in the center that I haven’t dealt with yet.

The header and footer are JPanels for which I created a custom UI. I won’t post the code here, it doesn’t really matter. There are many implementations of gradient panels on the net or we could use synth. The important thing is the window design with this style. The brushed metal style created a texture that spanned the entire window and drawing it was slow on older machines. This gradient is less complex that the gradient in the Swing Ocean theme. But you can’t just use the gradient UI with every panel. If the middle content area was a form with labels and text fields then this look would not work very well. I wouldn’t use it for dialogs.

There is a toolbar on the the header with floating disabled and transparent (not opaque). The JSeperators space things out — be sure to set their height to zero otherwise they draw lines. The search component is a blog for another day.

The “Article Title” header is a JPanel with the same gradient UI just with different colors. The “Article Title” itself is a JTextField with the border removed, not opaque, foreground changed to white, and bigger font. The combo box is set not opaque, that really only matters with Apple’s Aqua Look And Feel.

For the tree, we changed the background color. This creates a problem with cell renders still being white. I had created a custom cell renderer before hand to display the icons. Inside the cell renderer I change the foreground for the selected cell to white. Trying to change the background of the cell in the same place doesn’t work. Trying to set the cell renderer to transparent doesn’t work. Instead use something like the following…

        DefaultTreeCellRenderer ren = new CTreeRenderer();
        tree.setCellRenderer(ren);
        tree.setBackground(new Color(0xE7EDF6));
        ren.setBackgroundNonSelectionColor(tree.getBackground());
        ren.setBackgroundSelectionColor(new Color(0x3F7EDC));
        ren.setBorderSelectionColor(ren.getBorderSelectionColor());
        tree.setRootVisible(false);
        tree.setShowsRootHandles(true);

This looks pretty neat until you select a cell. In iTunes the entire row is highlighted and the highlight is a gradient. I don’t care about a gradient highlight personally, but I’d like the highlight to extend to width of the window. This likely means overriding the UI of the tree to pick the slack (see Tiger Trees) since the cell doesn’t actually take up the entire width of the window. That also means we probably couldn’t use synth to do it (even if I wanted too).

The “Document Title” area is a JPanel with the gradient UI again. The thumb button in iTunes is an extra widget to resize the splitter for people that have trouble getting their mouse on the one pixel divider. I haven’t implemented this yet (blog for another day). But the button itself is a PNG and the button set to not draw the content area or the border.

The name of the application is likely to change. I imagine the name I used in the screenshot is already used by some other application. And when I finish the application, it will likely be open source. More Later.