Thursday, March 12, 2009

Carousel for UI: Pros and Cons

I've played around with Swing 2D a little bit. Then I thought: OK, if images can be viewed in carousel, maybe it is good idea to show running applications? Like a shrink to thumbnails and show as minimized windows, sort of a'la OS X exposé? Here is how this thing looks like:

Yup, it works: you click on any other window that is not in a center or use arrow keys "←" or "→" and you move to another one.

Used as a dashboard. Completely bad idea, probably. It looks like "Wow!!" to user, however after 3 minutes user realizes it is a pain to use, because what he is suppose to see right away in front of his eyes is actually covered. Dashboard supposed to show you information right in a moment you spot it.

Used as a menu. Only for stuff, like Apple TV. I've built one for myself, using Freevo at my home, getting a cheap-small-macmini-like PC and putting it behind my TV. For such sort of software, where user wants to relax and see fancy transitions on a very big screen with five menu items — this is a good choice to use carousel view.

Used for multimedia. Well, Apple did that in iTunes and iPods. Me — shrugs. I don't use it and none of my friends I know. Somebody might like to grep over a pile of album cover pages and visually trying to catch one like "Yeah! That's it!". But I prefer have a convenient powerful search instead, typing: "Met<ENTER>" and get for me "Metallica" playing right now.

For something else? Maybe could be done as miniature composition for a minimized windows, like OS X stacks or something. But still it looks ugly, frankly. Because these windows will never be fixed WxH pixels, and thus will never look slick in this way...

Where to put this to make it really useful for people? I have to think more, seems like... :-)

Tuesday, March 10, 2009

Bastardizing Java Swing on OSX

Everybody knows: Java Swing on Apple OS X is in a stone age times and looks still ugly enough even on co-called native look and feel (do not mention Metal, please, I am drinking coffee now). Not just that, but Apple also playing quite funky games, screwing LaF all around. So what is OK for Java 5, is not really OK for Java 6. I even frozen to think what is coming with Java 7...

Recent development version of NetBeans 6.7 has better look and feel on OSX. But if you take a look more closely, you will find it is still far away from what should be actually done.

I've tried myself to play with it. Again, Swing by architecture outperforms SWT, that is still (and probably forever) is using Carbon, instead Cocoa. But that's very bad news to those, who is using it: Carbon probably gone in Snow Leopard. Swing, on the other hand, has a destiny to be permanently fake maker, drawing everything by itself.

Well, anyway. Focused and passive window looks like this for me in Java 5 and Java 6 for Leopard — notice also a scrollbar... :-)

Cool? No! I am actually very disappointed by... Apple. They're completely screwed Java 6 made it even worse than Java 5 (maybe because Java 6 was entirely handled by Apple?). Apple should push Java in front as a flagship product, but they're stick to Objective C, unfortunately (who the hell needs it on OpenBSD, for example?).

On one hand, the future of Java on Apple (and not only), however, is not that much dark anymore: it is at least open source (kudos to Sun). On the other hand, knowing how open source bazaar applies to projects — that's why X11 still sucks on desktops big time, no matter what you use there: KDE or GNOME (GUI No One Might Enjoy)...

Will see and contribute, right? :-)

Monday, March 09, 2009

NetBeans as a platform for software

I've just bit played with a NetBeans as a platform for my own plugins, created some and see how it works. I'd say, quite nice stuff, technically way better than Eclipse and overall impression is pleasant. You could use it for various desktop stuff, especially if you need IDE-like software and it is now. For example, if you want some management or monitoring system for enterprises that looks for doing business (read: looks damn ugly). Mostly it is very cool if you want to extend your system with various plugins etc. E.g. have UML modeling, but also have your own workflow builder etc.

However, if you ask me about software art or something serious, I would tell you that I would not use it for my projects (although I seriously considered NetBeans once).

Why?
  • It is too much "IDE-ish". Even an attempt to "make it right" as Blue Marine project [1] still contains too vivid smell of plugin-based platform. To get rid of it smell you need to remove a lot of things. It will suck more blood from your body that you just do it all yourself from the scratch.
  • Too heavy for JNLP. Even with one single "Hello World" plugin — almost 20MB.
  • You need do unnecessary wrapper-works and other hacks-n-tricks in order to use Swing-X components. Why?..
  • I don't like its Plugin Manager from user point of view (nothing wrong with it itself — works perfectly).
  • Plugin mechanism is too heavy and can be simplified to much lighter incarnation. It gets better, but still there is way too much XML.
Personally, I vote for minimalism or, if possible, extreme minimalism. I love to remove everything, unless it is just impossible remove everything else. With NetBeans, still, you have some persistent bits that I would love get rid of it for ever.

One curious thing: an author of Blue Marine complained that first attempt was actually done on a solution from scratch and he was completely unhappy with it, therefore he revealed NetBeans for himself. In fact, I am opposite... — the World is that different! :-)

_______________
1. Frankly, I have just zero idea who needs this thing on Windows with Google Picasa, on Mac with iPhoto and on Linux with F-Spot... Well, but anyway somebody has a fun, right?

Sunday, March 08, 2009

Usability From Redmond

I've just installed Microsoft Vista (fouling my holy CV) to make sure Java Swing GUI looks nearly as close as possible to this taste-less Mac OS X cloning failure. OK, one thing makes me happy: it is a virtual machine (easier to delete it all).

One moment that gave me good laugh how these M$ folks are trying to think about usability. OK, I do not need those ritzy widgets, maybe I even do not need anymore that quite big ribbon at the right side that serves them. So what I did: tried to close by clicking either "->" button or just dragging it away. Right?..

Wrong! Vista "knows better". They probably spent one more million dollars on a research how to handle what user wants to do and then suggest "right way". In my case, Vista asked: "Do you want to close side-bar?" — and offered me a "right way" how to do that. Of course, it is Microsoft way: you need to right-click on it, select an item from menu "Close side-bar" that is messed up with other items barely readable small font and then get a confirmation bubble that side-bar is closed.

Brain dead. Just brain dead. You've got it, Redmond, as you deserve the most: brain dead.

Friday, March 06, 2009

OpenSolaris 2008.11 on Virtual Box

I've just installed OpenSolaris (AKA "Slowlaris") on my new MacBook, using VirtualBox (screw you, VmWare!).

Overall, everything fubar, exactly as expected: now it finally boots from GRUB and does not hangs as before, trying to use AMD on Core Duo; network is OK and won't suck anymore, as it did in "Nevada" build; video barely works in a simple mode and VBox Additions won't help you out of the box.

To fix video working full-screen and seamless mode, it is needed to be manually fixed, by simply removing away all of those display resolution modes from /etc/X11/xorg.conf file and also setting up virtual machine with 64Mb of video memory.

Second step is audio that won't work anyway anywhere, unless you manually debug it again (as described above). First, throw away slim_install package, a waste of space dependency that keeps root of all evil: SUNWaudiohd package. After those two gone, get OSS driver for Slowlaris and install it (pkgadd -d package-file.pkg):
Open Sound System installation complete
You can use osstest command to test audio playback in your system.
It may be necessary to reboot the system before all devices get properly detected by the system.
Installation of OSS was successful.
Damn great! Unix follows now the most popular trends, exactly like in good-old WinNT times: install a driver, reboot the system...

P.S. Sound still sucks on Solaris big time and also randomly crashes (/usr/sbin/soundoff and /usr/sbin/soundon cures current random crash). Well, never mind, I don't need sound during packaging software and, besides, I use iTunes on my Mac anyway... :-)

Tuesday, March 03, 2009

Swing and Hibernate (feedback)

I've found an example how to use Hibernate in Swing.

Not to mention weird existence of HQL entity in general, you have to use it for the very trivial SQL request. Why?.. Oh, that's a "short-cut" to automatically generate very inefficient and wrong SQL query, I see.

You also need a pile of XML to configure your ORM. Then you need another pile of XML to map your database stuff to the objects through these entities. Ah, right, you also need those excellent entities themselves just to hard-design your application, thus making it rock-stubborn against any minimum changes, removing any possible flexibility without whole recoding and recompilation. After all at the end, you also need to hard-code your QUERIES_BASED_ON_VARIOUS_CRITERIA (look at the code in the example to understand what I am talking about).

*Sigh*... It is just all pathetic... Disappoints even more, than that anyone could expect. Hey, folks, wake up! ORM supposed to make life easier, not harder!.. Therefore, if ORM concept does not makes your life any easier but generates a mess of general hodgepodge, maybe quite correct logical conclusion would be to do not use it at all?

Legacy databases solves legacy problems. We need new databases and new approach to the data management. Thus having it simple and understandable: keep sets away from objects.

Moral: Keep it simple, stupid.

Monday, February 16, 2009

Java + Groovy

If you do not need a blazing rocket-science performance, but just need to toss up some prototype or even production software in Java platform, but you really-really-really do not waste time on Java language verbosity, you may consider using Groovy as a dynamic language extension to the Java platform.

Let's do something silly, but to see how the things are interacting between each other. For example, let's read our "/etc/passwd" into a list and display a first element of it from a plain Java, omitting an empty lines and/or commented ones. :-) Here how it is done in NetBeans IDE:
  1. Make sure Groovy support is in your NetBeans 6+. Usually it is there out of the box, but maybe some plugins must be installed. Check it by Plugin Manager, navigating to "Menu→Tools→Plugins" and see maybe you need some tweaks in Preferences for Groovy specifically.
  2. Create new Java Application project. Let's call it "JavaAndGroovy".
  3. In your package, called now "javaandgroovy" create a Groovy Class. Since it is an example, let's call it "Grovample".
Great. Now is a time to read the file with one codeline, as a text and return a list of the lines. Here you go:
package javaandgroovy

class Grovample {
def readfile(filename) {
List data = []
for (line in new File(filename).readLines()) {
line = line.trim()
if (line && !line.startsWith("#")) {
data.add(line)
}
}

return data
}
}
Now, to use this class in the plain Java, just... use this class! Like this:
package javaandgroovy;
import java.util.List;

public class Main {
public static void main(String[] args) {
List passwd= (List) new Grovample().readfile("/etc/passwd");
System.out.println("Lines: " + passwd.size());
if (passwd.size() > 0) {
System.out.println("First line: \n" + passwd.get(0));
} else {
System.err.println("Well, you're on Windows. :-P");
}
}
}
As a result, I am getting the following output:
Lines: 40
First line:
nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false
Now, let's look how the distribution looks like. Press "Clean and Build" button or simply navigate to your project directory in the terminal and run "ant" command. In a "dist" subdirectory, here is the following tree:
.
./JavaAndGroovy.jar
./lib
./lib/groovy-all.jar
./README.TXT
File "groovy-all.jar" has a weight of 2.7Mb. Not so small for very tiny apps, but not so big for bigger ones. You might consider put this lib in your GlassFish somewhere, in order to do not deploy it every time with your WAR/EAR. :-)

Keep in mind: Groovy is significantly slower than plain Java. Really slow. Check out it how much slower. Still, it does not means that we can not use Groovy for many-many tasks around and simplify our Java code.

Happy Grooving! :-)