scruffles.net subscribe
Saturday, May 12, 2007

It took me a little effort to get Idea's Groovy Plugin built, so I thought I'd share my experiences for those who don't want to fall in the same traps.

I started from some instructions on the forums, but still had trouble. Some filenames were wrong, and working on the mac changed some of the details. Here are my revised instructions:
  • Update to a new EAP of IDEA. The plugin wasn't built for IDEA 6
  • Checkout the project from http://svn.jetbrains.org/idea/Trunk/groovy/
  • When you first open the project, you may be asked to make a variable association. I pointed the templates variable to ${project}/resources/fileTemplates
  • I had to create a new Intellij IDEA SDK pointing it to my IDEA installation
  • Add tools.jar (on windows) or classes.jar (on the mac) from your JDK installation to the SDK classpath
  • Add idea.jar from your idea installation (on the mac, the file is /Applications/Selena-6951.app/lib/idea.jar) to your SDK classpath
  • There are already two ant scripts in the ant window. Run the one called generate lexer from groovy
  • Run the build>make command from IDEA's menu
  • Run the build>Prepare Plugin Module 'groovy' for deployment command from IDEA's menu
  • A zip file will be generated to the project directory. Copy it to IDEA's plugin directory and unzip it.
  • Restart IDEA
I've attached the file for those daring enough to install software from some stranger's blog: groovy.zip

Labels:

Wednesday, May 9, 2007

The large number of discussion about JavaFX over the last few days seems be very polarized. So far I have only read two opinions repeated over and over:
  1. JavaFX is the competitor to Flash and SilverLight that we've all been waiting for.
  2. JavaFX is a weak attempt to cash in on the recent SilverLight announcements and has no chance for success.
What most people don't seem to get, is that JavaFX isn't even in the same market as Flash and SilverLight. It's much more appropriate to compare JavaFX with XAML or Flex (just the markup language, not the action script, runtime environment, multimedia support or animation). Both Adobe's product line and Microsofts are made up of several packages:
  • A runtime environment - The Flash VM and the .Net Runtime
  • A declarative UI language including widgets - Flex and a light version of XAML
  • A declarative animation language - Flash and XAML
  • A scripting language for procedural logic - Action Script and JavaScript
  • A development environment for each of these three languages
  • Multimedia components - video and audio playback is supported well as first class components in both frameworks
Of course JavaFX runs on the Java runtime environment, and it defines a very nice language for declarative UI building and a decent language for animation... but that's all it tries to do. Sun has yet to show any interest in completing the rest of the picture.
  • It could be argued that some work would need to be done to the JRE before it could be light enough to compete with Flash or Silverlight as a runtime environment (at least ease of installation could use some work).
  • JavaFX has no equivalent to JavaScript. Although one could theoretically use Java, Groovy, Javascript or some other language for procedural code, the binding isn't nearly as nice as the integration the other two frameworks have with their scripting languages.
  • Netbeans provides some syntax highlighting and code completion for the language, but it's barely better than notepad when compared to the authoring tools being offered by Adobe. To take on the competition, Netbeans will need timeline driven animation and Matise-like component layout from day one. On day two, we need vector drawing tools to compete with Illustrator and Expression (tie-in with existing tools might be a nice stop gap).
  • Multimedia support has always been a weakness in Java. JavaFX is the neon sign pointing out one of Sun's often ignored weakesses.
With all that said, JavaFX compares very nicely to Flex and XAML when ignoring their sister technologies. Feature for feature it compares nicely. Without the rest of the package, of course, it's all pretty academic. Assuming Sun is really serious about taking on Adobe and Microsoft, they still have a lot of work ahead of them.

Labels:

Monday, March 19, 2007

I went to a .Net User's Group meeting about WPF tonight. The speaker was Walt Ritscher. The presentation was a pretty decent intro. I was expecting it to be quite a bit more in depth. I guess I figured .Net developers would already be up to speed on WPF and an intro presentation would be beyond them at this point. I seem to make a habit of setting my expectations a little too high for most user group presentations.

I recently signed up for a membership at lynda.com, which provides instructional videos on many technical topics. The subject matter tends to lean towards creative tools (Photoshop). I've been watching the Flex training videos and I can't help notice the similarities to what Microsoft is doing with WPF. Macromedia really seemed to have missed the boat by brining application development to Flash so late in the game, but they seem to be catching up well now that Microsoft has put some fear into them. Since Adobe took over, they've kept going strong.

Of course both Flex and WPF/E are both proprietary technologies that have fairly useless free SDKs and $600 development environments for the serious user. I haven't seen any free alternatives with anything close to the capabilities. Both SVG and F3 have similar capabilities, but F3 isn't open and lacks the development tools and SVG lacks good browser support.

Oh well... guess we'll have to put up with Ajax for a few more years.

Labels:

Tuesday, February 6, 2007

10 years ago Sun introduced Swing, and with it, JavaBeans. JavaBeans were supposed to allow UI widgets to be defined as components. It would allow Swing developers to take advance of graphical layout editors without vendor lock-in. It failed.

Those who tried to develop Swing apps with their IDE's drag and drop editor forced their way through limitations and learned how to hand-code fixes that wouldn't break their IDE's code parsing. Then support would dry up for their favorite tool and they would be left with no alternative, but to hand-code their Swing apps. Others recognized the graphical tools as Microsoft-style lock-in and avoided it early on. For almost a decade, hand-coded Swing apps have been the norm.

10 years later, Sun is trying again. They seemed to have missed the point of their initial failure. They seem to be under the impression that had the first tools been of higher quality, people would have never resorted to hand-coding their Swing apps. In reality, it was the proprietary nature of the IDE-generated code that caused the failure. No matter how well the tools would have worked, Java developers have been conditioned to demand vendor neutrality.

Vendor neutrality is not something developers get from Netbeans and Mattise. As nice as the platform is, the code it generates is not parseable by any other platform. Because it doesn't generate code to a standard, such ad-hock compatibility wouldn't be enough anyway.

This problem has already been solved, of course. Ironically, one of the latest solutions is from Microsoft. Although XAML is a closed standard, it is a standard. It's well defined and parsable by multiple editors. A Swing solution wouldn't have to be as feature heavy as XAML. There are many open source solutions that fill the need. Of course they would need to be adoped by Sun (presumably via a JSR) and the IDE vendors to be a useful vendor-neutral solution. Until this happens, Mattise is just another way to lock your application to your IDE.

Labels:

Saturday, February 3, 2007

I'm not sure when it happened, but at some point since I started using IDEA I lost the concept of saving my source code. Since version 2* IDEA has automatically saved changes when focus to the window was lost. I don't really know how long it took, but over time I stopped paying attention to file saving. From time to time, I would edit a text file in notepad or use someone else's IDE and bang my head against the wall as I tried to run without committing my changes. Apparently it was a common mistake. Eclipse eventually added a warning dialog: "You have unsaved changes. Would you like to save them before you run your program?". What the hell kind of question is that?!? Why would I have changed my code, and run my program if I didn't want to see those changes reflected in my application?!?

I guess having a warning is better than what notepad does... but then again, is that really the mark of a great IDE: "at least we're better than notepad!"

*version 1 of IDEA was a JBuilder plugin, so it might have been a little silly to do it then

Labels:

Thursday, February 1, 2007

I've been reading about the various proposals for adding properties and events to the Java language. In the process, I stumbled across an interesting blog entry by Richard Bair which he starts by describing why JavaBeans don't break encapsulation. For a long time, I've believed Javabeans were an abomination. Despite the intentions of the creators a technology is eventually defined by how it is used. With the exception of a couple dozen Swing components, the JavaBeans patterns is used by most developers as a loophole allowing programmers to break encapsulation.

When Richard describes the original purpose of JavaBeans, he's describing a framework that was needed very badly for allowing tools to interact with components. If properties and events are added to the language, it would go a long way towards cleaning up the interface between components and their tools.

What I don't see it helping with, however is the programmer's understanding of what they are doing when they make a component. When someone implements the JavaBean pattern, they are agreeing to an existing contract. I know very few programmers who understand that contract. None of them seem to understand that they are building a component. They have been told by the good people at Hibernate or the people who made their databinding framework that they were making plain-old-java-OBJECTS.

Plain Old Java Objects. Like every other Java object out there. But Hibernate doesn't work with just any Java object, does it? It only works with Java objects that strictly meet the contract set by the JavaBeans pattern.

Of course the market has picked the term POJO to emphasize the difference between today's tools and those requiring implementation of multiple interfaces and the addition of specific behaviors to your objects. As horrible as those frameworks were, they were object-oriented. Of course, since the buzz of the term object-oriented hasn't died down, we don't want to tell people that we've transitioned them to component-oriented programming already.

Labels:

Monday, January 15, 2007

When moving my blog to from Movable Type, I noticed a handful of posts that were still unpublished. One was a reference to a tool I put together about a year ago. It's a status screen for Cruise Control build results. If you're monitoring more than just one project, lava lamps are a bit of a pain.

Labels:

Friday, January 5, 2007

Intellij has made their roadmap for version 7 available. I don't see anything real exciting at this point, but I'm usually more impressed by their implementation than their feature list.

Labels:

Friday, December 1, 2006

I'm going through some old java code ('96ish) that has collected some odd band-aids over the years. Most make me scratch my head. I just ran into one that was at least documented. As strange as it was, I guess at least I know what the devloper was thinking:

The data members of this class must be alphabetized so that connections can be processed by VisualAge for
Java, and some were renamed using rather peculiar names in order to allow the alphabetization of
the fields.

Labels:

Monday, August 28, 2006

Over the past few months, I've run across quite a few good sources for Java programming information. I thought I'd share a few here:

Ben Galbraith's Professional Swing: Creating Polished Apps was originally presented in the No Fluff, Just Stuff Symposium. The first section is basic entry level stuff, but the second part (Professional Swing: Threading) hits some topics that many Swing developers overlook. If your still making database calls from your event listeners, please take a look at this presentation... your making us all look bad, and we need you to stop!

If you're having trouble keeping up with all the latest changes in the Java world, and have more than a few minutes of drive time in the morning, try downloading The Java Posse. I was really surprised how much interesting information they have to talk about. They go through a very good mix of topics each episode (not like many web based news sources such as digg, slashdot, the servers side, etc).

JavaPolis has been offering a DVD of all they presentations at the event. I got mine a few months ago for around $50 (give or take after the exchange rates). There's a lot of good material on the disc. All of the presentations are in the same flashed based format as the Swing presentations above. Many are the same presentations presented at Java One. Sun has also posted the presentations from Java One on their site, but I haven't gotten to take a look at them yet.

Labels:

Wednesday, August 9, 2006

If you believe that ignorance is bliss, then you want to avoid 'Java Concurrency in Practice' by Brian Goetz. In fact you may want to try to avoid talking to anyone who has read it. I've only made it halfway through, and I feel like the little kid in 'The Sixth Sense' -- I see bugs everywhere. When I close my eyes, I see code I wrote six months ago - BUGS! When I open them I see them in the projects I'm working on, and the ones I maintain.

These aren't big, bugs that cause everything to stop working every time. Nope. These are those little strange ones. When you upgrade your server, and that app you haven't changed in 2 years suddenly starts spitting out an incorrect value every couple days.

And these aren't race conditions or deadlocks. Most programmer I've worked with have at least a basic understanding of how race conditions can occur (at least I like to think they do). The bugs I'm talking about are visibility bugs. Values hiding on the processors cache, that don't get flushed back to main memory (yes, it's java, but it still runs on a computer).

Java Concurrency in Practice does a very good job of explaining these kinds of issues and how to deal with them. I think it does a much better job than Doug Lea's book, which I'm sure is packed with knowledge, but isn't very accessible. In comparison, Java Concurrency in Practice is much more conversational. It's also (of course) much more up to date.

On a side note, I bought this book at the prompting of my IDE. IDEA kept highlighting threading issues in my code. Its explanations seemed very strict, and I wanted a better explanation of why it thought I should change my code. I thought for sure it was making assumptions and making an issue out of nothing. But since IDEA had always given me good advice in the past, I thought I'd look into it. Any decent IDE will teach you the language's syntax or api (via error highlighting and auto completion), but it takes a pretty damn good IDE to teach thread safty!

Labels:

Saturday, June 3, 2006

For those who are looking for good technical discussions to listen to on the way to work in the morning, Bruce Eckel has a very interesting series of interviews available. I've listened to about half of them now, and some are very interesting. I epecially enjoyed the interviews with Tim Lister and Ron Jeffries.

On the downside, my reading list (which was already a bit unrealistic) has grown by a couple books as a result of listening to these interviews.

Labels:

Wednesday, May 17, 2006

Have you ever known someone who still confuses relational databases with flat file structures? Someone that would rather have the application define data relationships than constrain them in the database? I would like to propose a compromise with those people by introducing a new sql keyword. Take a look at the new might-be constraint:

alter table SCHEMA.MY_TABLE add might-be constraint MY_TABLES_FK foreign key (ASSIGN_ID) might reference SCHEMA.OTHER_TABLE(ID);

Labels:

Wednesday, April 26, 2006

It's hard to explain why you can like a product like IDEA. One whose feature matrix wouldn't even hold up to a 4 year old copy of JBuilder. But it isn't that container managed enteity bean wizard that saves you from pulling out your hair. Its these thoughtful little features that never make it to the feature matrix on the side of the box:

Labels:

Thursday, March 2, 2006

I've been using IDEA since version 2.5, but still a couple times a week, I stop what I'm doing to laugh a little at some small but brilliant feature that helped save me. The one I found today was even more trivial than usual, but it still made me smile.

When I see the red squigglies I now instinctively mash the keyboard: ALT-ENTER. Before I even read the message; before my brain has even interpreted the line of code my cursor sits on, I mash the keyboard. This time, here's what I saw:

I was looking at this thinking about how the system knew I should call getPredefinedCursor(). I still can't come up with a generic rule that might have been triggered by this situation. Somewhere in IDEA's code, there's a rule waiting for me to pass an integer into a method as a Cursor, so it can popup this intention. Not that is attention to detail!

UPDATE: In a comment (not transfered from MovableType), Keith Lea points out: "The general rule is that for a call to M(X x) passing value of type Y, IDEA suggests any static method in class X which returns X and takes only Y as a parameter."

Labels:

Friday, February 10, 2006

I imagine by now, everyone has seen the Waterfall 2006 Conference. In the spirit of their Refuctoring presentation, I would like to present an interesting topic: "Design Driven Testing"

In Design Driven Testing, your painstakingly crafted, flexible code
determines the types of unit tests you write. Because these tests will need
to exercise your code without requiring changes to the design, they
may need additional complexity. But as everyone knows, it's easier to test one big method than several small ones!

Some implementation suggestions:


  • Generate test data - since your methods under test are now large and complicated flexible, your test data needs to be a bit more complex. With a few well placed unix scripts, you can generate the java code necessary to test your java code.

  • Use smoke tests - There's no need to test every possible combination of inputs. With a large flexible method, that wouldn't be very pragmatic. Instead, try a happy-path test. If you can run the logic through a couple common scenarios, it probably won't break when boundary conditions arise. Feel confident in your programming skills!

Labels:

Tuesday, October 4, 2005

I�ve been reading a book on the Windows Presentation Foundation (Avalon). When I got to the chapter on panels, I was pleasantly surprised. Panels control their own layout (rather than having multiple layout managers, WPF has multiple panels that have different layout behaviors). The panels available in WPF seem to mirror those in Swing, with many subtle, but powerful advancements. Many of these advancements are glaringly obvious to anyone who�s used Swing more than twice: Why can�t you stack more than one thing in the north location of a BorderLayout? Why can�t you specify that the sides get control of the corners in BorderLayout rather than the top and bottom? Why does GridLayout always have to stretch my components? There are many of these simple little annoyances that drive developers directly to using GridBag for everything (or adopting a third party library).

Sun believes they are just setting the groundwork with Swing, and leave it to the third party developers to make further advances. I find this to be a cop out. Why can�t Sun spend a couple weeks of man hours to clean up the existing layout managers. They already have things 80% there (they were good enough for Microsoft to copy from). But for years we�ve seen no improvements from Sun (Spring doesn�t count as an advance - a step backwards, maybe). If Sun wants us to believe that Swing isn�t dead, maybe they should stop treating it like it already is.

Labels:

Tuesday, July 5, 2005

I like to analyze my co-workers' to understand how they think. Understanding my co-workers helps me work better with them, and gives me a little perspective on my own future direction. One of the early indicators of how well I would get along with a co-worker was how much they liked technology. I found myself much more interested in working with others who had the same passion for programming that I've had. After a while I found that not everyone who loves programming is especially good with it. I've found that a lot of it has to do with early programming experiences and what philosophies of programming they consider important.

For example: Which of the three basic principles of object oriented programming do you find more important: polymorphisim, encapsulation or inheritance?

Those who say inheritance value the ability to change an objects behavior. They aren't as interested in this for the sake of masquerading one object as another (or they would have said polymorphisim). Instead they find it important to repeat as little code as possible. People who find inheritance very important have a tendency to inherit from unrelated objects simply to pick up behavior. They tend to believe in deep hierarchies and flexibility in object models, even if it risks complexity.

Those who prefer polymorphisim also love design patterns. Some like polymorphisim because it makes for elegant code. Most like it because - let's face it - polymorphisim is cool. It makes you seem really smart. I don't mean to make fun of these people. Polymorphisim does help you write some very elegant code sometimes. I just don't think it's an especially important tool in writing good software.

I put myself in the category of programmer who believes encapsulation is the more important characteristic. With encapsulation you separate responsibilities cleanly and provide easy to understand code. Someone who looks at well-encapsulated code has much less to understand before being able to make changes. If there is a downside to leaning this direction, I haven't found it yet.

Another question that may explain a lot about your programming personality: What is more important to you in application code: reusability, flexibility, maintainability?

(Side note: I debated about putting Performance in the list above, because I've known many programmers who would place Performance above all three other choices on the list regardless of the purpose of the application. I didn't include it because I believe this is a decision based on ignorance rather than preference or philosophy. I don't consider ignorance to be a personality trait.)

Those who favor reusability fall into one of two camps: Those who subscribe to the DRY principle and don't want logic repeated in multiple places; and those who think the idea is to minimize the number of line of code in a program (as if it makes the code more maintainable to share code between unrelated pieces of logic simply because they look similar when you do a text compare against them). The former group has a very strong argument, and while I don't disagree with the philosophy, I simply don't rate it as high as others. The later group should be shot. Fired, then shot.

Those who think that flexibility is more important than reusability or maintainability are very hard for me to deal with. They believe that if they can write the code, then anyone with an education should be able to read it. Therefore, maintainability is not an issue and they should instead dedicate their time to making the code do more. These people usually don't have the social skills to deal with the domain experts, and write flexible code to substitute for communication. Since agile methodologies have become more popular, this programmer has had less and less ground to stand on.

Personally, I find maintainability to be the most important thing to keep in mind while writing code. Code is in maintenance far longer than in development. There are also far more remedial programmers than advanced programmers. Much more cost goes into maintaining code than developing it, and the ultimate goal of any commercial software is to make or save money. I find maintainability to be more important than reusability because maintainability is the driving purpose behind reusability. Why DRY? So you can make the change in a single spot. So you can read the code easier. Why is encapsulation so important? To make it easier to maintain the code. I find maintainability to be at the root of all good software decisions, and I think it is ignored way too often.

So what do you value, and why?

Labels:

Wednesday, February 2, 2005

Once upon a time, in a land far, far away, a large manufacturing company spent many months and an untold fortune on a system to print RFID tags for their product labeling. IBM was entrusted to make the technical recommendations. Here�s what they had to work with:

The company as a whole is an International mega-corporation, whose primary source of technology is Microsoft. The engineering division contains a small group of Java programmers who write mostly Swing applications. They have a couple servlet apps, and recently introduced their first JSP app (although only two programmers have any JSP knowledge). They have never used J2EE (in fact I doubt anyone would be able to accurately describe J2EE). They deploy only to Windows (even their servers run on windows).

So based on that, what do you suppose IBM�s recommendation would have been?

A J2EE app running on Linux using a front end based on Portlets? Sure! Why not? When all you sell is hammers�

Labels:

Thursday, January 13, 2005

Most middle managers seem to have a large knowledge gap when it comes to web apps. Very few seem to understand that HTML is a markup language meant to format text. Any other use of it is the result of a series of clever hacks. Because those hacks have been so successful, many don�t differentiate between web applications and any other application. The lines between possible and impossible, and cheap and costly seem arbitrary to them.

After years of fielding some seeming ridiculous questions, I decided we should cut out the middle man. Management should skip the developer and ask the programming components themselves to do the job. What would happen if technology could talk, and we removed the developer from the equation?

PHB (Pointy-Haired Boss): My web reports need more advanced printing. I�d like to allow the user to check off all the reports they need to print and press a single button. Then all the reports should print at once. How long would it take you to implement that?

HTML: Why are you asking me? I just format text.

PHB: Format text? My web applications are written in HTML. Surly you do more than that?

HTML: Actually I don�t even really format text. I just mark it so CSS can format it. I used to format text, but someone decided that would be too much responsibility for one technology, you see, I also link to things. You should talk to the web browser. He knows how to print.

PHB: I need to print a bunch of reports from a web page. Can you do that?

Internet Explorer: Sure. I can print web pages. Just load one up, press the print button and repeat.

PHB: No. I want to press a button in the web page to cause many pages to print.

Internet Explorer: If you want to press a button within the web page to print, you need to talk to Javascript. But I'll only print one page at a time, no matter what he says.

PHB: Ok. Javascript, how do I initiate printing from within a web page?

Javascript: If you issue this command, I can pop up the print dialog for quite a few browsers: window.print(); � I can�t promise anything though. Ultimately, its up to the browser.

PHB: Can you print more than one page at a time?

Javascript: I can only pop up the print dialog for the current page. But I can also open as many windows as you want and pop open the print dialog on each of those? Then you would have a bunch of windows, and a bunch of popup dialogs. Or I could open a single window, popup a print dialog, open a new report in the same window, and popup the dialog for it�

PHB: Can we just have one print dialog?

Javascript: All I can do is open the print dialog for a single web page. Maybe you could talk to the app server about getting everything on one page for me. For as much as you paid for him, he should be able to do anything!

PHB: Good idea. App server, can you help me with something?

ISphereLogic: I�m a massively scaling, on demand, multi transactional, threaded, secure enterprise application environment. I can do anything.

PHB: Can you merge multiple pages together so they print all at once?

IsphereLogic: Well� I have minions who can. Try Servlet, JSP, Struts or XSLT. They should be able to help. If they don�t you could talk to any of the CGI solutions, ASP or one of my more proprietary cousins.

PHB: I know my developers were using Struts before. I read about it in InfoWorld and had them switch everything over to Struts because it got 4 stars in the CIO Report. I�ll ask him. Struts� can you help me?

Struts: I am only a controller. I do not handle any trivial matters such as view or data. You should talk to JSP.

PHB: Ok, I�ll�

Struts: But first, you must subclass Action and add entries to web.xml, struts.config and tiles.config before I allow you to talk to him.

PHB: err� kind of controlling, aren�t you?

Struts: It�s what I do.

[15 minutes pass]

PHB: JSP? Can you put these reports on a single page?

JSP: Sure, as long as the data needed is here and the application server lets me. It will probably work.

PHB: I think I have it working, but this sure seems like an unstable house of cards. I hope nothing goes wrong. It sure would be nice if there were someone between me and these technologies to blame if it did.

PHB: Hmmmmm?

Labels:

Bryan