Monday, March 26, 2007

Project Acta Diurna - Harnessing RSS Goodness for Project Glory

Last week I was bitten three times in quick succession by a lack of knowledge about what was going on around me in the rest of the team. On the flight home my mind went back to prior occasions when the same thing had happened. We all know the drill - there's a bug which seems to make no sense at all; we keep think we're getting close to understanding what's going on when something happens which blows all your carefully thought out theories clean out the water. Later it turns out that you weren't the only one pulling the levers and pressing the buttons on your environment. You'd forgotten or not known about the CruiseControl builds, or the recent changes to the DB schema, or the fact that a firewall had recently been installed in between your web server and app server, or that someone else was on the envinronment at the same time, or..., or... etc. You get my drift.

The fact is, we've all been there. Wouldn't it be lovely if we didn't have to worry so much about all this I mused. What if there was a single port of call where you could go to find all this information, the acta diurna (day's events), before we got tied up in these knots? Somewhere like a project dashboard?

As I disembarked from my flight and collected my bags things coalesced in my brain. As I waited to be picked up I started to scratch down some ideas.

What Should Acta Diurna Do?
It should be able to collect and diplay in a single place all the daily goings on on a project. You know, the big important things such as RFC's, show stopping bugs and team nights out. But lets not forget the not so important things too; SCM check-ins, wiki updates and password changes on the dev DB server. Why not just carry on as usual with a mixture of verbal / web page / IM / email comms? The answer is in the question - these can come at you from all angles, you can miss out on them, and when communicated verbally you can forget them or lose where you wrote them down. Even if they're on web pages, they're spread everywhere. The aim is not to formalise things, but to make them simpler.

So to make things simpler it need to be simple itself, the reader especially. Why can't it just be a single file containing both the HTML and Javascript needed to keep itself up to date? Lets keep a hold of this simplicity and not place this on a web server. Lets just email it out (re mailing when an update is needed) and store it locally on everyone's system (on the desktop or in "My Documents" or something.). Now we don't even need an internet connection. Finally lets have it as everyone's homepage.

But that's the very simple end. What about the RSS feeds themselves? Research and prior knowledge tells me that there are already a lot of feeds available for us out there within our development environment. Our project's wiki might have them already baked in; so might our bug / issue tracker, SCM and continuous integration tool. Lets not complicate things unnecessarily. Lets just subscribe to them.

But we could collect even more. What about blogs? I don't mean this kind of fat, complicated blog, I mean the quick thought / announcement / thinking out loud kind of blog. More in the vein of Twitter than anything else. These could be used for announcing RFC's, RFE's, RFO(pinion)'s, re prioritisations, UAT test results, nights out, things for QA, general project news, specific team news, changes to environments, things that have been learned, architectural events (i.e. major refactorings), developer blogs, and new and interesting things (bookmarks etc.), and more. And lets not stop there. Then there's the files that are generated such as project plans and spreadsheets which normally silo their info. Lets open them up too and listen for changes. Lets embrace the potential of RSS goodness.

What About What's Left? KISS the Server Side
As mentioned, the feeds for some info is already there. What infrastructure needs to be put in place for those where it isn't? Again, it needs to be smiple. This should not add to administrator workload or significantly slow down project startup time. It seems that two sub systems must be added to the equation:
  1. A set of plugins to produce RSS feeds from the information sios which need them (to begin with a simple blogging server could be set up to provide the blogs. If this provided too complicated and high maintenance, a home baked, super-simple blogging engine could be added to the mix)
  2. A HTTP server which can serve these centrally to be read by the dashboard clients
This is where I start thinking Ruby- JRuby specifically. Why? A few reasons
  1. Its a languge well suited to quick development
  2. There are libraries already available for creating RSS feeds
  3. It seems to me that Webrick is a simple web server sitting waiting to be used - needs to be investigated
  4. If we use JRuby it can all run within a JVM. Moreover a 1.4+ JVM. There is already likely to be a box with one available, and it not that's easy to set up. In addition, if we need a database in the future (user - configurable pages anyone?) we could use embedded Derby

So What's Next?
Well, first off I need to come up with the dashboard page. I've seen an example on which I'm certain can be pretty simply cannibalised and turned into something usable. This can be immediately plugged into some resources via native feeds in things like TRAC or the loads of extras available for free for things like Subversion and CruiseControl. Other human originated feeds could initially be distributed in the form of very short posts to specific blogs. These need not be available externally (in fact really should not be) but can be set up for the purposes of the project.

Then the next job is to have a hack about and write the simple RSS generator for one of the info sources we'll need and serve it up from Webrick running on a JVM.

Final goodness could be to slowly find or replace the third party RSS enablers with some activa diurna versions - "One throat to choke" and all that. That way we could have a suite of simple plugins to RSS-enable many of these elements in a consistent and predictable way. The idea is for this to grow and be used in as many places as possible. It'll be FOSS which hopefully will mean others will step in and give me a hand with it. I'm off now to create the dashboard. I'll blog again when it's done...

NOTE: I should point out that this post owes a fair amount to seeds sown by reading about RSSBus and XFruits (Thanks Scott); take a look. They're very cool and I think would play very nicely with this once it is up and running.

Powered by ScribeFire.

Saturday, March 17, 2007

Sun Tech Days (London), Day 2, Report 4 - Extreme GUI Makeover

Note: My battery ran out half way through this session but I think what I got is worth putting up. You can get the source and slides from the session when it was done at JavaONE 2006 here.

Slightly worryingly the metaphor chosen for this presentation is to compare your java app and your daughter. You love her and spend lots of time on her right? You want her to look good right? Errrrrr OK... Things get a little safer and we get down to the code... Cultural differences are a wonderful thing.

Java 2D Basics

Get the Graphics2D object and then you can change the rendering context. E.g. stroke (lines), fill, composite (overlap two images), transform, clip (don't show the whole picture based on a certain shape) and rendering hints (e.g. anti aliasing)

Example code: [Shows fill and clip. First fill with a gradient and then clip with a round rectangle.]

Example code: [Shows Composition. AlphaComposite class. SOMetimes you want to show the source, sometimes the destination and sometimes both. Once ou have set the composite ( with setComposite( ) ) you can set the overlap of the image.]

SwingX Project
Java has a very strict process if you want to change the default behavious of a Java class. Sometimes you want to extend of change the basic behaviour but to follow JCP can tajke 2 years. Swing Labs was created on which contains several projects including SwingX which has very basic components which extend basic components extending basic swing (e.g. JXTable which makes sorting and highlighting is easy).

See the code: [Shows the SwingXDemo from Netbeans]

There are native look and feels for different platforms

Timing Framework
We are all fans of cartoons and animation makes your application more "adorable". There is a swing class called Timer (in javax.swing). It has an actionPerformed( ) method which is called when time passed and you do some animation.

But you have no easy way to define the diration of your animation. Also, what if ou want to make your app go in reverse? There is no way in Timer. The Timing Framework was created (on
  • Cycle: This defines how long an animation will last.
  • Envelope: You also define how often your callback method is called.
  • TimingTarget: The new callback target - begin( ), end( ), timingEvent( fraction ) where fraction is the fraction of the total time passed since the last callback
First create a TimingTarget. Then create an Animator (with duration, repeatCount, repeatBehaviourand target as arguments). Then set the animation resolution (how often to call the TimingTarget) and the end behaviour.

Finally you call animation.start( ) to start the animation.

[Another demo from the Netbeans examples (Timing Examples project) - a button moves. Another demo - racetrack. This has sound.]

Welcome the Supemodel (A Mozilla Thuderbird Clone)
  • Sexy border - DropShadowBorder (extends basic border). You create a ShadowFactory to create a shadow for whatever you are shadowing.
  • If you use DropShadowPanel the shadows are made for you. It extends JPanel and just need to create a single ShadowFactory and then add things to the Panel. They will all have shadows created for you automatically.
  • CoolBar - Extends the standard JToolBar. Done by overriding the paintComponent( Graphics g ) method
  • CoolButton - extends JButton. Every JButton is a rectangle. CoolButtons need not be. Cool. You can even make them translucent... Apparently it's "pretty easy" by using Composite and set the opacity to 0.1f. Sweet.
  • Fade in and Fade out - Use the TimeController to use animation which you start when you detect the mouse has moved in and start again when the mouse moves out. You can do the same thing to make it step in and out of opacity...
  • Customising Fold Tree - override getTreeCellRendererComponent ( )
Running out of battery!... Ded.

Wednesday, March 14, 2007

Sun Tech Days (London): Day 2, Report 3 - Impressions

The Tech Days almost over. Here are some of my general impressions:
  • Its very well attended
  • Laptop platforms of all flavours were evident everywhere - Linux (SuSE, Ubuntu, ...), Solaris, MacOS X, Windows. The Sun obsession with hating MSFT seems to be waning... A good thing.
  • People have been using SunRays without knowing it. Another good thing...
  • Java on the desktop is coming! A vast majority of the SE 7 pitch and 80% of the cool demos face off focussed on it. It looks great native too. Has anti aliasing ever been given as high a profile before in a general conference?
  • Other (dynamic) languages are having a great effect on the language and platform. You can see dynamic syntax, semantic. Even thought patterns and expressions were spotted. E.g. "Syntactic sugar". Roll on JRuby, Groovy, Scala, Javascript and the rest...
Disclosure: I used to work for Sun between 1998 and 2005.

Sun Tech Days (London): Day 2, Report 2 - Derby DB

Sun Java DB, a Small, Easy to Use, Pure Java RDBMS - Oystein Grolven
[Less than half of the audience have heard about Java DB]

Introduction - Short Intro
What is it? Its the database for Java. For development it should be the natural chioce.

It is a Sun-supported distro of Apache Derby. Same binaries. It turns out that more people in teh audience have heard of Derby. The difference is that Sun provide support. It's bundled with Java SE 6

What are the main characteristics? Its a complete RDBMS engine. It can be embedded (in the same process as your application) or operate in client/server mode. It is designed to be easy to use - "no DBA".

It has a small footprint, is compact and mature and is written in pure Java

Originally it was called Cloudscape and was started in 1997(?). Then it was acquired by Informix and subsequently by IBM "where it was silent" but was used in >100 applications from IBM. In 2004 IBM donated Cloudscape to Apache and called it Derby. In 2005 Sun started to add (commit) to it. Today there are 20 developers in Sun working on the Derby project.

It graduated from the incubator (i.e. it had a strong enough community and more than one company behind it) in July 2006. In Deceber 2005 Sun announced Java DB. The current release is 10.2.2 and is bundled in JDK 6.

Within Sun it is used as the default DB in Glassfish, Portal Server and Service Registry as their data storages and is also in tools like Creator and NB.

  • Written in pure Java (therefore runs on the same multiple platforms your app may run on)
  • Write once run anywhere - requires a J2SE 1.3 - Java SE6 VM
  • Database on disk format. I.e. stop the app, copy the db files to a new platform and restart. It all just works again
  • It's embeddable - then access is just a method call within the JVM. It's a single JAR file in your classpath and it is invisible to users and is easy to use with zero maintenance. NOTE: while embedded it can still act as a server
  • Client / Server mode is also possible
  • Small footprint (2MB engine footprint - inc. by ~150k for a network server and another ~200k for tools). Runtime memory cache dependant on app and data caching. It has been run on machies with 16MB memory
  • It's based on standards - SQL and JDBC. There are drivers for JDBC 2.0 - 4.0
  • It also runs on top end mobile phones with the CDC configuration (where it uses a sub set of JDBC defined by JSR 169).
  • It is a complete relational engine - multi user, tx, isolation levels, deadlock detection and crash recovery
  • You can use standard SQL
  • It can be encrypted by using a single Java library
  • It can use Java stored procedures and you may call Java functions from SQL. To call back into the DB engine, use standard SQL connection URL
  • Security - on disk database encryption. Can authenticate vs. an LDAP DB, NIS+ and pluggable authentication. It also provides ANSI grant/revoke priviledges support. Java security manager can be enabled.
  • Architecture: SQL is compiled into byte code and can be optimised by the JIT compiler. The downside is that compilation and class loading has to take place. (therefore prepare and pre compile your statements). There is also a pluggable storage layer - file system (all in a file in a dir.) or read only in a Jar file, or an experimental in-memory version. In the future: HTTP, email, etc.
  • Tools - ij (interactive SQL scripting tool using JDBC), dblook (schema extraction tool which generates the DDL to be used to recreate DB scehma), SQuirreL, sysinfo
  • Embedded in the same JVM - easy to use, fast, zero admin. Can only be accessed by one app at a time (though this could be e.g. an app server). To start, there is no specific startup code - when the driver is loaded it starts. [Horiffic syntax though ("Class.forName...") - to be hidden in the DriverManager in SE 7. Shutdown by exiting the JVM. But this is not controlled. You will have to redothe logs from the last checkpoint. Therefore you should do a shutdown with jdbc:derby:[dbname]:shutDown=true; via a connection request. NOTE: This may throw an exception
  • Client / Server - Network server is an added layer between the client and the embedded DB. Stadard protocol (DRDA). Allows you to use scripting.
  • Security - enable user authentication. Might be useful to enable the Java 2 Security Manager. Therefore procedures and fuinctions will have no permissions. App code can be granted permissions.
  • Embedded Network Server - A combination of both. Therefore both network and same-JVM clients can connect. This adds DB reporting and debuging. Done with "derby.drda.startNetworkServer"
  • Read only DB in a JAR - use on e.g. a memory stick. Simple to distribute.
  • DB in a browser - It is small enough to fit in a browser. See demo at Good it you have AJAX and you can avoid the delay of talking to a server. Then you can synch up periodically. Also copes with browser crashes so you don't lose data
In short it could cover and benefit all three tiers of a Web Application

It performs well. It compares well to the competition. Comparisions are OK against MySQL and PostgreSQL (with a TPC-B like load , main memory DB, DB 10MB, page cache 50MB not so good, but when DB size inc. to 10Gb, page cache 64MB it tops MySQL)

To Avoid Performance Hits:
  • Use and reuse prepared statements
  • Put the DB log and data on separate disks (specify the logDevice attribute when creating the DB) which avoids the disk head contention
  • Tune the page cache size (the default is 4MB) -
  • Use indexes to avoid table scans - check query plans with derby.query.logQueryPlan = true;
[Then there is a demo of the tools: ij and SQuirreL]

Features in this (last 10.2 release)
  • XQuery support
Features in next (10.3) release
  • DBA powers
  • Secure Server by default
  • SSL / TLS between client and server
  • Language based ordering
  • Alter table enhancements (drop / rename columns)
  • More performance improvements
  • BLOB / CLOB enhancements - support for the entire JDBC API
Disclosure: I used to work for Sun between 1998 and 2005.

Sun Tech Days (London): Day 2, Report 1 - Gosling Keynote and Sun and Darkstar demo

Pre keynote
Waiting for the keynote to start I see guys demoing an SL based (WRONG! It's Darkstar based - I should have known. Less lag ;-) (?) collaborative working env. called MPK20 (Project "Wonderland"). I'd never heard of it before but it looks very cool. I need to find out more. They showed how you can take your screen and share it in the virtual world and there are also noticeboards and common areas where you can paste up shared information. Each developer has their own office. Cool

Then they show Project Glassfish. There is a good crowd round the demo. Comparisons to Vista and the usual MSFT dig (shame). Otherwise exciting.

... the keynote is starting (video from Jonathan Schwarz). You get the distinct feeling that here under the dome the voice of god has spoken ... A little scary.

The next guy comes out. He's RL and more worryingly he's Californian. It gets worse. He has a beach ball. Everyone recoils in horror but then the mention of James Gosling gets a spontaneous round of applause. Now there is an announcement that there is going to be an unconference at the end of the day. Interesting to see if this catches on in the UK. Only ~10 put their hands when asked if they'd heard of the format...

Simon Ritter is up now. (Apparently the previous guy was called "Ricky"). Apparently 11,000 developers came to the developer days in Hyderabad (2.1% of the GDP in India is attributable to Java we are told). Unfortunately after Ricky, it now feels slightly like the Sun has gone in... Can I feel the wind start to pick up?..

James Gosling - "The Future is Open"
The Java landscape still has a great deal of innovation even though the VM and language has been stable for a long time.

We're on the road to ubiquitous computing. The network is spreading out to some really interesting edges and feeding on itself. 4 "Anywhere's" (Enterprise, Standard, Embedded and Card- interesting to see card up there still). The embedded world is tracking Moore's law pretty tightly. Its putting lots of stress and evolution in the APIs.

Java's Role: Conceptual framework which spans the network. It enables a homogeneous view of a heterogeneous reality; an ecological view. It's "learn once work anywhere". Its a realitively small step from Java on the desktop to Java on a coke machine, or in the enterprise. All the core learning carries forward.

It's used everywhere: Brazilian NHS (tracks every patient in one LDAP database and tracks every patient interaction across the entire country), giant telescopes, JPL, protein folding, eBay, Orbitz (Jini gets first mention ), FedEx (more Java developers than Sun), financial, web apps, games (e.g. A.I. engines)... It is now on > 1 billion handsets. There were 54 million JRE downloads in January ('07)

Web2.0 is now but what were the generations of technology? Early on it was rocket scientists (NASA) with bare metal and floating point operations. This hasn't gone away but it has morphed and grown. Thick client comes alon and now common within enterprises. Then Web apps. But what is "Web2.0"? Personally Gosling would delete the phrase from the vocabulary. It is a composite label for a bunch of underying ideas. What is in and what is not in the bundle depends on who is talking. The big thing is it's a lifestyle. (pic w. iTunes, Gmail, Yahoo,Google Maps, SalesForce, Rails, Basecamp). It's not the pure push models. Now the community is involved (Flickr, YouTube). In these sites they have produced almost othing. The content is generated by the community by their interactions with the services. They (Flickr and YouTube) provide the framework. You do the (s)mashing up.

It's a development model. It is very community oriented. People talk about Open Source (again it means so many things to so many people - forJames it's not the source it's the community. It's about collaborative development. People all around the world working to make stuff.) Then standard elements become important i.e. identity. What does your user look like?

A big thing has been AJAX. ("Gee you guys just realised you could do this? The browser has been capable of this for 10 years. Duh it's been sitting there"). What is important is not JScript and XML, it's the realisation that HTML alone does not give you a very good UI. Enhanced interfaces are possible. If you're doing forms use HTML, otherwise, it becomes difficult.

The JVM. It;s the integration hub. Most people forget about it. There are about >100 languages running on it. Many are not for all (Jmes wrote a Fortran 77 translator a few years ago for it "because he's stupid"). However the JVM is a mediator.

Weaving thrOUgh all these pieces is secuity. It's woven into the JVM. You don't go to the shop for anti virus software for Java. It doesn't need it. People have built all kinds of security sstems on it (banking, healthcare)

But this becomes inherantly complex. One of the jobs of the community is to battle it. The focus has been Java EE. 5,0 dealt with complexity via common scenarios by exploiting annotations and generics.

Historically people focussed on the API and the languages. Now it's also handled by the tools. Tools like Netbeans. It has a tremendous amount of work gone into it to simplify things. The app servers have also done the same (glassfish). All these pieces are developed in a very communal way. Sun showed the Java source since 1995. The only thing which changed was the licence.

Tying all the seperate dev.processes together is the JCP. Kind of like a standards organisation but kind of not. The big thing happening at the moment at the JCP is how to open up the process itself. List of JSR's. Mine (JSR 310) hasn't been mentioned yet but the point is that they are about simplifying things such as JSR-277 - the modular system.

JCP components are three fold:
  1. Specification - what is it for?
  2. Reference Implementation - can it be built?
  3. Compatability Test Suite - is my implementation complete?
Netbeans! (announces the slide). One of the big things for Sun is the tools. A lof of complexity can be addressed by the tools. E.g. GUI development. "Swing is the most powerful UI toolkit on the planet." But we want to make not only everything possible but easy too. A lot of work has gone into Matisse - it has an A.I. constraint based model to guess your alignments. It is trying to avoid absolute positioning so that it scales and internationalises properly.

NB also has a lot of support for enterprise dev. EJB, WS, debugging on the app server is greatly simplified.

Also refactoring, version control. More and more is being covered all the time.

[Aside: he's using a Mac for his presentation. He also seems to have written the slide presenation program he's using... Envy! Update: I'm told this is Huckster]

The desktop world has been changing. AJAX has driven the realisation that HTML does not produce a compelling user experience. THere is more than one desktop platform that people care about now. not just Windows but also Linux and OS X. (James refers to the perso app he's using and how it runs on any platform). The court cases with MSFT have been settled now and the JVM is ubiquitous. Web Start gives you a web-like way to find an application and download, install and run it. It does all the caching and version management. Plus if there is a new version of the system then it will do auto upgrades.

GWT - an interesting thing developing from AJAX. You write in Java but compile to Java script. The problem with JS is that there is so many different versions of it out there. When you use the GWT you can run on a pretty seerious spectrum of browsers. It's using Java to easy JS development.

Aligning the edge. So we have all these things on the edge, from the desktop, to cable TV, BlueRay, IPTV and mobile. They have all grown up somewhat independently. They all have APIs which are not too aligned. Aligning the APIs, E.g. mobile are growing up - they are converging towards Java SE. There is coming the MSA (Mobile Services Architecture) which declares standard functionality sets which different mobile devices support. There is also always the need for tools, tools, tools. To hide complexity and make development for multiple platforms easy. Not everyone is a developer and not all developers write code.

Macinac - real time code. JSR1: Realtime specification for Java. Originally desingned for extreme real time control in real world systems with complex sensor control feedback loops and a lot of scheduling.

What happens when you run an app server on a real time VM? It's damn quick per request almost always. On non realtime every now and then there are "excursions" while the system does a GC or a recompile. You just don't see it on realtime. SO why not all use the real time VM? There is a trade off betwen determinism and numbers. To get the max no of requests processed / per sec? Use the normal system. It exploits the common occurances and can gain much that way. You can't do that on real time.

Moore's Law. Moore's law was about # transistors, not clock rate. They aren't really getting that much faster not. Now it's a shift from clock rate to #'s of cores. Years ago, poor performance was OK because "whe things speed up on teh hardware we'll be cool". Now you must think about it. Java has a lot of support for multi threading. If you're lucky enough to do EE dev. you're protected. Otherwise...

The myth of Java performance... Dynamic compilation beats static (e.g. processor specialisation). Hotspot knows what silicon it is sitting on and will optimise accordingly. AMD can get stuff in and out of memory much much faster and better than Intel can even after Intel's recent speed bump. One cache miss means your app can slow down a lot.

Open Source. "Yes we really are going full open source". There are three reactions "hooray", "huh" and "no don;t you do that". There will be no compromise on quality. Just becasue there is a GPL licence on it does not mean anyone cancheck it put, change and commit. To become a committer the hurdles will be pretty strenuous. Most people who submit patches have broken 5 other things. There needs to be some policy for submitting so that they won't be looked at unless they pass the whole test suite.

[They hope to have moved to a new VCS by May.]

Which version of the GPL? GPL2 (+ the classpath exception) now but Sun are working with the GPL 3 folks.

So what comes next? Java is driven by the community. There is no way I (James) could have come up with all the wored and wonderful things that have been created by the community. Sign up to the community. Comment, create, debate participate. Do as much as you can to create something "really quite special". Enjoy your time. Thankyou.

Then rubber Duke's get thrown... Apparently we're (i.e. the British) harder to crack a smile on than even the Japanese.

Disclosure: I used to work for Sun between 1998 and 2005.

Tuesday, March 13, 2007

Sun Tech Days (London): Day 1, Report 1 - First Impressions ++

It's a beautiful day outside. I've taken the tube to Green Park and walked past Buckingham Palace to Westminster Central Hall, venue for the Sun Tech Days 2007. I'm here for the Netbeans day....

...It's now 9:07 and we're waiting for the first session of the first day to start. First impressions? Good so far:
  • Wireless internet available across the board? - Check
  • Good range of geeks? - (Worryingly) yes
  • Free pens and t-shirts lobbed at us? - check. Also the old pre dot-bomb stress balls are back. I get one by answering a question. That's 3 I have now...
  • Wishing I had a Mac laptop with a fluorescent keyboard? - Yes
The only downside is the turn out. The room is not packed. There must be ~200 folks here. (I take it back. The place is busy now (10:00). Hot too) (Disclosure: I used to work for Sun. I don't now. I still have a die hard attachment to them however. Kind of sad really...)

The first session has kicked off... Octavian [Somebody] - The Director of Netbeans Engineering welcomes us and runs down some basics:
  1. It's looking good. Roman Strobl is to do the first session. That was not on the agenda sent out.
  2. First off is the Netbeans strategy. (also JRuby gets its first mention on a slide)
Apparently Netbeans is an:
  1. IDE
  2. Platrofm
  3. Community
Then we get some history and a sales pitch - NB works "out of the box" and we have our first dig (and only it turns out) at Eclipse ;-)

..."It's also fully supported - Sun are also selling piece of mind"

Now we have a Roadmap:
  • Netbeans 6 goes beta in May 2007. FCS mid Nov. Preview for JavaONE
  • NB 6.1 start mid October, release may 2008
  • NB 6 to support scripting and dynamic language support. AJAX and more heterogeneous language dev.
  • And exitingly at milestone 7 we got Ruby support.
What will we hear next? What's New and cool: Matisse. JRuby and BlueJ

Roman Strobl Demo 1 - Swing Application Framework and Swing Data Binding
To kick off he gets the crowd onside with a joke about the pain of GridBagLayout. He then does his first demo - Matisse and NB6's support for 2 JSR's: 295 (Swing data binding) - which allows you to bind a data source to a component and the Swing applcation framework (I don't know the JSR)

He then does a demo of both (note that this an the other demos are freely available at the Netbeans World Tour Wiki):
  1. New project type - Java Desktop application
  2. Choose application template - two are available now
  3. Select the db connection and table and columns
  4. Choose data view layout
  5. The NB IDE will then generate a simple application for you (entity class, and swing frame menu with icons, "about" box, actions and menus)
  6. Roman then shows the app running. If you resize columns and window. close and reopen and it remembers it. Cool
  7. We then see data binding: examing field properties and dialog pops with binding. Roman adds new component (slider) and resizes it. He then selects "bind", selects the binding in drop down in dialog and runs the app again.
  8. Roman says it has full CRUD support. Double cool.
  9. He then Creates a new record. (New car; a Skoda) and persists it.
  10. To examine the car he then drags a new bean (car pic) and bind to db again (colour, moderness).
  11. He runs the app again, moves the new "moderness" slider and the car shape changes. Getting even cooler.
  12. Roman points out that property change listeners are created automatically. If you change something and it just happens.
  13. Finally he adds a check box. (Roof window) , binds it to the picture and runs again.
Conclusion: "Swing data binding you can bind data very easily"

Now we look at the source: has been created. Its a Java EE 5 entity class (POJO with annotations used to specify mappings.) Encapsulation and change listeners are automatically generated in code.

Roman also points out that the Swing Application Framework supports actions. If you add a button and link it to an existing action (or create a new one) it lets you set button, label, method name etc. in a single dialogue. - Impressive

All in all this is massively exiting. The only problem is that you can't try this functionality yet. It will be in the next NB milestone (8). There was a visible sense

Roman Demo 2 - JRuby
Roman asks who in the room uses Ruby? I'm the only developer in the room who admits to using it. (I get a free stress ball). That's interesting. I wonder what the response will be in a year's time?

He then asks who should care? - He brings up a table showing data from Tiobe. Java is #1. But it is not growing. Ruby is only language growing rapidly.

He points out that Sun recently hired the JRuby developers. He says the aim is to create a bridge between the Ruby and Java worlds. Time for another demo...

How do we get it? From the NB update centre. This demo will focus on the editing. He trails the fact that there will be more demos tomorrow in the Netbeans Extreme session.

We see:
  • Code completion (with RDoc) V hard to do. Can see docs inline
  • End block completion
  • CTRL-Shift-F reformatting (and to use 2 space indents - Ruby standard)
  • Regex has code completion too - Sweet!
  • If you add a string reference and if you have not declared it, the editor adds it for you.
  • Roman then adds a unit test . Unused variables are shown greyed.
  • Marking appearances also works.
  • In place renaming - Super cool. That produced a general sharp intake of breath...
  • Code completion on imports
  • Right click- run file.
Roman's done. He went down very well.

BlueJ (guys from Kent University) - Mike Kolling, Ian Utting
These guys work in the University of Kent Computing Lab. They have been working for a few years on BlueJ

They point out that BlueJ is a development environment. NB is another. They point out that how do you go about learning OO? It is a paradigm shift even if you can already code procedurally.

They introduce the debate around whether you should you use an IDE at all? Yes they say - just use an IDE which does what you want it to.

BlueJ was specifically designed to teach OO concepts. They estimate that it takes 18 months to make the mental model switch. Traditional IDEs do not support this. The size of things such as NB itself can be intimidating - the number of options etc.

But even if you have something like BlueJ how do you then move across to Netbeans at a later stage? With the help of Netbeans BlueJ edition. (There is also something for schools teching called Greenfoot - out of scope of this presentation)

Then they start the demo. BlueJ has a very simple UI. You start by opening a project and it's UML classes are shown on a central canvas. The IDE has four main buttons - New class, Extends, Uses, Compile

If you right click on a class you can create an object from the class and it appears in a new canvas below the main one. We can now see all the methods by right clicking on the object. There are some on our demo object (a shape) like "make visible", "move right" etc. If you click a method it runs. If you click one with a parameter then you must enter this via a dialogue. There are also packages

So you can use and inspect methods. You can also see all the values of fields an objects. You can move an object on the run canvas by changing its state (e.g. v. position) You then see the object move on the run canvas and its atttributes change in the object inspector in real time.

They point out that we have so far totally avoided the semi colons and "public static void main". Before the Java syntax we learn classes, objects and encapsulation. This is how to learn OO.

Then we finally drop down to code. All code is based around allocating behaviour to an object.

They then make the point that one of the hardest things to explain to their students is the difference between a class and an object. Looking at the code they frequently think it is both. But what you show on screen is what they will think about. If you want to show interacting objects, show them interacting objects.

They say that you should start with this to teach object orientation. But there is more. There is a debugger. You can still write and execute code. They use this at University level for 1 year. It runs on the standard SDK. There is no point which can be reached when you need to move up to a next IDE. It is a matter of choice.

They make a few more points. You can automatically invoke any public method stand alone. You need not hava a main method again. You can also round trip between code and diagram. If you create a class then the template code is automatiically generated. They also use it to teach concepts of unit testing. You simply create a test class which automatically creates a JUnit test for you. You then use BlueJ to record a series of UI interactions to use for the Junit test. E.g. yuo call a setter to set a value, and then a corresponding getter to see it was set and there is an assert box to check that this is correct. You then stop recording and then run the tests. You can see the green bar. Its just like a fully blown IDE. They note that you can also run just tests for a single class or even just a single method.

So that was BlueJ. What about Netbeans BlueJ Edition?

Picasso (paraphrased) - "Its not finished when you can't add anything else. Its finished when you can't take anything else out."

So where do you go from here? NB BlueJ is based on 5.0. Its like straight NB but with a lot fewer menu items, and panes. At this phase the confusion is still a problem they note. J2EE is cut out completely. Other stuff is present but switched off using the module system.

They also point out that this version understands BlueJ projects directly. They open a BlueJ project view (next to projects view) to demo this.

When first transitioning a student may want to move back and forward between Netbeans BJ and BlueJ for Java they say. It can do this. They can still go back to BlueJ at any time (e.g. to use the test recording)

Now we want to start to add some IDE features. This uses NB module management. They enable something using the standard Tools ... Module Management dialog. Initially they show that there is no refactoring enabled in BlueJ NB Edition. The refactoring menu appears straight away without NB stop/start.

They point out that this avoids the cognitive overload of not having menu items which you don't yet use. Again it avoids the "what the hell does public static void main mean?" question. If you don't want to introduce it yet, don't show it. But then you also want to add it easily when you do want to cover it.

They then add a "player" to their Zuul Game demo. There is now a BlueJ set of file types in the "New File" dialogue. We need to give our students the the boiler plate for free - don't give your students a blank page. In Java there is a lot of boiler plate they point out. A beginning student is not equipped to differentiate this from the important stuff. BlueJ templates are simply added to NB. They are sucked out of the BlueJ instllation so again synch is maintained with the other tool.

They conclude - "Allow your students to transition to their eventual IDE step by step."

Session 3 - Subversion and the Netbeans IDE
To be honest this session was pretty dull. It didn't help that the delegate came along in a suit and tie. How to lose a developer audience in one easy step... The interesting points are as follows:
  • SVN was developed for the web. Designed for distributed dev. SVN always sends only the deltas across the wire providing better performance than CVS which may send the whole thing.
Key Features:
  • Versioned directories which support versioned renames
  • Versioned metadata
  • Atomic commits (change set) - good for when your network fails
  • Global revisions
  • Support for both models (concurrent and block based) for parallel development
  • Support for WebDAV - the whole team can use it
  • Choice of network layers, back-ends and client applications
  • All files treated as a string of bytes - equally efficient with word doc or ascii file (over wire and back end)
  • Branching and tagging are not seperate concepts. SVN has more of a file-system-like paradigm. There are files which are on or off. You the developer decide to mark something as having a tag or being a branch. It is therefore far quicker than CVS to tag or branch a large project
  • You can easily diff two branches - Do a recursive diff between two version trees. Netbeans supports this in the UI, as does Tortoise
Netbeans plugin support
  • Merging branches support - there is a wizard dialogue
  • Searching history and diffing - again visually supported
Podcasts and webcasts:
  • support in NB -
Q: How easy to migrate to SVN?
A: Collabnet does a lot of work in this area. Problem is knee-jerk response is to want full version hostory migration. This is impossible. Also it takes a lot of effort. The question then is how far back in history do you go? Go to a stated point and then leave the rest in e.g. CVS. It is harder to do with Clearcase. The design is far more divergent (i.e. branches at the element level). How do I map it to SVN?

Java EE 5 - Did you get your tools with that? (Brian Leonard)
This session was an introduction to EE 5 but using NB as the demo IDE.
  • WS 2.0
  • JPA
  • JSF - now part of the spec.
Brian points out that the spec sprung from Hibernate, Spring and XDoclet. As specs evolve, they tend to get more complex. This took stuff out.

It leverages annotations, uses POJOs and dependency injection and relies on more and better defaults (effectively the Ruby "principle of least surprise" thing)

He notes that
  • Java EE5 is backwards compatible with J2EE 1.4
  • Deployment desciptors are still there if you need them. Gets over the "annotations are in code" problem. External edits to these files override annotations.
Brian asks "who here doesn't use Netbeans, and are just here to see what's going on?" (10-15% raise their hands gingerly). This is also interesting to see. The crowd is both a lot less a) synchophantic or b) hectoring than the crowds I'm used to when NB is mentioned. This is a good thing. Netbeans seems to be moving towards a mainstream acceptance.

The demos were very simple (thought they did go wrong because Brian had to borrow Roman's Czech laptop) and I won't go into detail here other than to make the following points which I found interesting:
  • If you just mark a POJO with @WebService then it will be a Servlet Web Service. It only becomes a Session Bean backed Service if you also add @Stateless or @Stateful
  • JPA 1.0 is not a persistence provider. It is just an abstraction layer. You are not tied to your persistence provider. I mention this as there is a common misconception that JPA is basically Hibernate / Toplink / etc. etc. depending on your heritage.
  • We see auto generating a basic JSF CRUD app with only an pre existing set of database tables. First we auto gen the Entity beans from the DB tables. Then we generate the JSF web app using the Visual Web Pack. Again this is a few simple steps in a wizard. All the code generated is standards based and ANT projects
[My laptop then runs out of battery...]

There were two more sessions after I ran out of battery. Roman went through a very swift overview of the extension packs available for NB. Profiler (interesting, load generation is coming in NB 6.0 with integration of JMeter), C/C++, Enterprise Pack. HE had to rush and little new was revealed.

Finally we had a talk and demo on the Mobile Pack. I don't know much about mobile development (though I have done some fiddling) but this was very impressive. We saw support for SVG, on device debugging, connecting mobile apps to Web Services, and how to develop your application for more than mobile platform at any one time (you can swap the platform you are coding from a simple drop down. The pieces of your code which will no longer work on the chiose platform are shown. You can add special comments to either remove this problem codewhich was demoed or provide alternative code blocks to do something different for your platform. Netbeans manages the complexities of all this from this point onwards.) It was very impressive.

Although we ran out of time I was very impressed in what I saw this morning. No demos were canned. Contrary to expectations they had flown in some of the real "rockstars" of Netbeans (Roman and Brian) and they delivered the goods. It is only a shame that they could not have used this in the marketing for the event. These guys might have managed to draw an even bigger crowd.

It's also good to see the UK getting a bit of Java love. Does this mean that Sun sees bespoke development becoming more of a big thing over here, closer to how it is perceived in the US? Possibly. They're certainly bullish about their offerings and competition (within the standards) is always good. More tomorrow. Including James Gosling.

Friday, March 09, 2007

Running JRuby built from the trunk with Netbeans 6.0

It's nice to use software in development. It's also nice to use it with an excellent IDE. What fun then that you can use easily use Netbeans 6.0 to both build and develop with the absolutely latest version of JRuby. Here's how.
  1. First you need to get Netbeans 6.0. You can download the dev build from NOTE: you currently need to get Milestone 6 or above so choose Netbeans Version "6.0" and Build Type "Daily". Get the latest "IDE" product.
  2. When it's downloaded, double click and install...
  3. You're not ready to go yet. You need to connect to the update centre in order to get the Ruby support. Click on Tools -> Update Center to start the process.
  4. From the available list of options select all the Ruby elements and install them.
  5. Now you need to get the lastest JRuby source. To do this you need to set up Subversion to point to the project's repository. Click on Versioning - Subversion - Checkout...
  6. Enter the JRuby trunk repository URL: svn:// and click "Next", and wait...
  7. When the code is checked out and Netbeans has scanned the classpaths it will ask you if you want to open the project. Answer in the affirmative.
  8. We're almost there. Now we need to build JRuby. To do this right click on the Ant icon in the "Projects" pane and select "build". Ant will build everything for you.
  9. Now set two environment variables. The first, a new one called JRUBY_HOME which should point to your base JRuby directory. Then add $JRUBY_HOME/bin to your path (%JRUBY_HOME%\bin on Windows)
  10. Time to get Rails. Open a command prompt and type: gem install rails -y --no-ri --no-rdoc
  11. Finally you need to point Netbeans at your JRuby binaries. Select Tools - Options. Select the "Miscellaneous" tab and expand the "Ruby Installation" node. Point each of the items at the binaries in your JRUBY_HOME\bin directory
That's it. Try creating a new Ruby project and then running it. You're off!

Placing your outside your application JAR

If you want to deploy your application as a JAR, and DO want it to be configurable via a file, but DON'T want folks to have to crack open your JAR to update it you'll need to do the following.

In the META-INF/ file add the directory location (relative to the jar itself) of your file to the "class-path" attribute. E.g. if your file is going to be in the same directory as the jar, then add "." to the end. If it's going to sit in ./config, then put this in the path.

NOTE: Remember, files have a maximum line length. Go over it and things get confusing. For more information on JARs and manifests see the Sun guide.

Thanks to Rob Newsome for his help in figuring this out.

Wednesday, March 07, 2007

Friday, March 02, 2007

Ruby with Foxes...

I've been learning (J)Ruby with foxes... Now all I need is Rails with whales and I'm all set.

Thursday, March 01, 2007

Truncating tables in DB2

If you have a table full of data and want to just drop the lot you can truncate it, just as you can in Oracle. The command is:
db2= alter table [tablename] activate not logged initially with empty table

DB2: Finding the maximum / minimum / average value in a given column

db2= SELECT MAX ([your column to query]) FROM [your table to query]

Showing a Table's Foreign Keys with DB2 Control Centre

Might be obvious to some. Not to me...

  1. Start Control Centre and connect to your database
  2. Select "Tables" for your database from the tree in the left hand panel
  3. Right click on the table you are interested in in the tables panel on the right hand side and select the "Alter Table" option
  4. Select the "Keys" tab in the new window and voila.