More on Eclipse RCP

I had problem building a working RCP application, so I put together the RCP Text Editor Example to see how to configure a RCP app.  If you want to build it yourself, instructions from the main RCP page at Eclipse site is below.  The page is actually a view into CVS, so I expect/hope the real main page will appear in the near future.

  1. Download the RCP Runtime build from the Downloads page, and extract it to a folder such as c:\texteditor-example.
  2. Download the RCP text editing component zip and extract it to the eclipse/plugins subfolder.
  3. Download the texteditor plugin zip and extract it to the eclipse/plugins subfolder.
  4. Replace the eclipse/configuration/config.ini file with the appropriate config file from the texteditor plugin. For example, on Windows, copy config_win32.ini file from org.eclipse.ui.examples.rcp.texteditor_1.0.0 plugin to eclipse/configuration and rename it to config.ini.
  5. Run the eclipse executable: For example, on Windows, run eclipse.exe.

Step #4 is the key step while the rest are just downloading and expanding files.  After step #5, you should see a barebone text editor.  On Win32, the RCP text editor has disk footprint of 6MB and memory footprint of 28MB.  In comparison, NotePad2 has disk footprint of 540K and memory footprint of 4MB.  SWT apps I built before had substantially smaller footprints than the RCP app, but still significantly larger than native apps.

So what do we get for roughly ten times the footprints?  Plugins!  You can put together a fancy standalone IDE for Perl, Python, or PHP by packaging plugins from the EPIC, PyDev, or PHPEclipse projects with RCP.  You'll need to pour some sweats to glue things together because those projects are probably not fully RCP ready yet.

If you are not building an IDE, don't need IDE like level of extensibility, or there aren't many plugins useful to your product, you are probably better off skipping RCP and building on top of just SWT instead.

Eclipse Workspace Corruption

I had to recreate one of my Eclipse workspace again.  Last time, it was because Sysdeo plugin was acting strange.  This time, it was the IDE itself getting confused (either JDT Core or UI module).  As usual I used QuickFix to import a class I referenced but the class still could not be resolved.  When I rebuilt the project using an Ant file, everything compiles perfectly which confirms that it was a JDT bug.  But my rebuilding of the project made JDT recheck all the classes and, since it was confused about the class I imported, it marked all the classes that used the imported class as having errors.

This would have been bearable if the confusion got cleared up on restarting the IDE.  Nope.  For some strange reason, the IDE persisted this confusion into the workspace.  So I rebuilt the workspace and the problem went away.  Sheesh.  I'll bet 3.0.1 will be released sooner than the scheduled September time frame.

TDD for ADD and Chickens

I like holding amusing thoughts.  Here is one.  Suppose you are incredibly talented and creative but you have the attention span of a chicken.  And you have to cross a road to, well, get to the other side.  TDD helps you do that by laying down a line of green beans across the road.

In midst of my first TDD run, I paused a little too long and ended up refactoring a little too wide and too deep.  Although the extent of the changes I made were about what I am used in non-TDD refactoring sessions, I immediately lost track of what I was doing.  It was as if I ran though several areas of Quake and getting overwhelmed instead of clearing one area and one monster at a time.  Restoring the green bar took a while and the fun/beat/rhythm dropped.  Once back in safe territory, I kept each step small and the fun was back.

Test-Driven

I started reading Kent Beck's Test-Driven Development: By Example over the weekend.  Tim Bray mentioned the book a while back and his impression of TDD differed from mine so I figured I was overlooking something.  Boy, I sure was.

I thought TDD (Test-Driven Development) was just development with a strong emphasis on tests.  It's more than that.  What threw me off was the word 'development' which encompasses the entire development process including design, implemention, evolution, etc.  The core gem of an idea behind TDD impacts the design phase most heavily and it's uncovered in rather tedious detail by Kent Beck.  Tedious yet startling is what I felt.

The simple idea is this:

Design software by writing tests first.

By 'software', I mean services, frameworks, modules, components, and objects.

Since tests are written before the module being tested is written, the experience of writing of the test drives the module's designing process.  More importantly, you are looking at the API, of the module being designed, from the API client's perspective.  Net result is higher quality API design.

While TDD during the design process is enough of a benefit for engineers to put into use immediately, TDD has problems because test cases are software and there are maintenance cost associated with them.  Having a tool like Eclipse helps but much more is needed to help the engineers document the tests, keep track of them, and reuse as needed.

I think a visual tool that lets engineers drag and drop tests into test suites for various purposes like release testing, runtime testing, diagnostic testing is essential.  TDD also encourages refactoring through out the development process which calls for more flexible source control system than CVS.

TDD Experience:

It ain't real until it's real so I put TDD into practice to write a small module.  The experience is definitely different than the usual way of designing and implementing software.  Deep thoughts are pushed to the background where it continues to churn while I am hacking and slashing in frenzy to make the JUnit bar turn green.  Everytime the bar turns green, deep thoughts surfaced and I dutifully jotted them down before I dived back in.  It felt very much like the way I felt while playing an intense video game.

To get started on a module, I just created a separate Java project using Eclipse because I could just drag and drop classes into the main project when I am done and Eclipse takes care of all the refactoring automatically.  I then added an empty class which represents one of the objects in the module I am writing.  No heavy thinking there.  Just something to get started with and refactor later.  I should have created a JUnit test case first, but it doesn't really make a big difference at this phrase.

I then created a test case for the classes and filled it in with a bunch of TODOs.  Eclipse picks up those TODOs and populated the Problems view so I can easily keep track of all the outstanding tasks in this TDD run, sort of like the missions view in RPG games that lists all the tasks one has to perform to clear an area.

I replaced the first TODOs with code to instantiate the object and then made an method call.  Eclipse flagged the line immediately because the method didn't exist.  I clicked on the flag and selected a QuickFix command that told Eclipse to create the method.  Wham.  It's there ready to be filled in.  Since I just want the bar green, I made it return a constant string value which should have been fetched from elsewhere.  Back in the test case, I wrote an assert statement that checked for the value.  I then rigth-clicked on the test case and selected Run > JUnit Test.  Woohoo.  I see a green bar!

This process was repeated at a furious pace over a couple of hours, during which I continue to added more TODO items and change TODO items into DONE status until there were all DONE.  Through it all, Java classes and JUnit test cases were added, removed or refactored.  In the end, I got a nice module with reasonably easy to use API and a set of test cases.  Whew.  What a workout.

Is TDD effective?  I don't think it's for everyone just as not everyone enjoys playing video games.  But it was productive for me.  I got more immersed into the design than I normally would have and finished with a more polished end product earlier than I would have.  Usually, I would render a first cut of a design and then sit on it for a few hours to a few days to get the kinks out.  With TDD, I went through tens of iterations per hour.  So the speed of development is definitely not a concern for TDD although I did feel a bit of adrenaline withdrawl symtoms at the end of it.

Will I do it again?  You bet.  I have to get to the next level, don't I? 🙂

Update:

I thought I should make it clear that I am not a proponent of TDD and I am not recommending it to everyone.  TDD is just a new tool I am adding to my bag of tricks because I find it useful and I enjoy the experience.  As I wrote above, I don't think everyone will find TDD useful.  It's up to you whether decide to try TDD or not.  If current style of development works for you, I don't see why you should look for something else.

Eclipse RCP: The Early Days

I played with Eclipse 3.0's new RCP (Rich Client Platform) support which allows you to build client software using the same engine that drives Eclipse 3.0 IDE.  While one could have build a client using just SWT, RCP allows you to reuse many of the Eclipse plugins in your application.

In essence, RCP allows you to easily repackage Eclipse 3.0 IDE such that it only has the features you want presented in the way you want.  Dependencies between plugins will complicate and bloat your RCP application, but I am expecting many RCP-ready plugins to be available soon so this is not a big problem.

The big problem, for now, is the lack of RCP tools and documentations.  Eclipse 3.0 has very little built-in tools to help you create RCP applications.  For example, Export Plugins feature to export a test RCP app but it didn't automatically include the necessary plugins.  So I had to write an Ant script to do that.  But then my sighs of annoyance turned to urghs of disgust when Eclipse deleted the Ant file when I ran the Export Plugins again.

I had a lot of trouble running and debugging the RCP app too.  I followed the instructions in the RCP tutorial exactly, but the startup code kept complaining that it couldn't find the application.  Looks like I'll have to dig into the plugin startup code and understand it more throughly.

In conclusion, I think RCP is wonderful but it's still a bit early.  Wait a few more months before diving in unless you can't afford to wait.

Eclipse C++ Development Tools 2.0 Released

Version 2.0 of the C++ Development Tools (CDT) which turns Eclipse into a C and C++ development environment was released on July 2nd although there is no evidence of that at the Eclipse CDT page yet.

You can either download the binaries from here:

http://download.eclipse.org/tools/cdt/releases/new/

or install it via Eclipse update tool using the following URL:

http://update.eclipse.org/tools/cdt/releases/new

Eclipse 3.0 Plug-ins I Use

Best part of using Eclipse is the large plugin developer community.  Since it could be a little bewildering, here are some of the plugins I am using with Eclipse 3.0.  They are all free and most of them are open source.

Color Editor - Free, Open Source

While Eclipse ships with syntax coloring support for many file types, it does miss some major ones like HTML, JS, JSP, CSS, and even XML.  The last one is a surprise because XML syntax coloring plugin was one of the example plugins offered by the Eclipse team.  Anyway, Color Editor adds syntax coloring support for 74 file types by porting syntax coloring files for JEdit, a popular pure-Java editor, to work under Eclipse.  Very nice.

Sysdeo Eclipse Tomcat Launcher – Free, Open Source

If you do anything with Tomcat, you'll have to get this one.  There are several other plugins that lets you do the same, but this one sucks the least among the free ones and the author seems to be still mildy interested in keeping it up to date.  JSP debugging is a bit of a hassle, but not quite enough for me to wade into the source code to fix it yet.  I am hoping another talented sucker will have less patience than I.  Heh.

QuantumDB - Free, Open Source

With this plugin, you can bookmark databases, browse them using a tree GUI, and execute queries on them.  Results are displayed in a grid.  Not exactly impressive, but very functional and very handy.

Azzurri Clay – Free Core Version, Not Open Source

Clay allows you to edit database schemas visually similar to the way MS Access does it.  It's not a tool I use everyday but it's very useful when you do use it.  You can create a diagram out of an existing database, make changes to the schema model, and then generate SQL dialect-specific SQL.  This is pretty handy for porting your database to another database implementation since Clay will generate the target database specific DDL.

GEF - Free, Open Source

Graphical Editor Framework is a framework for, surprise, building graphical editors like UML diagram editors, etc.  This plugin is used by many other plugins (i.e. Azzurri Clay) so you'll have to get it eventually.  Only issue I have with GEF is that it doesn't support Java2D yet.  Since Eclipse 3.0 adds support for AWT, JFC/Swing, and Java2D, I am hoping this shortcoming will disappear soon.

I also have EMF, SDO, XSD, UML2, and VE plugins but I haven't used them yet.  Visual Editor (VE) plugin, in particular, should be very useful so I am going to play with it this weekend.

BTW, I usually go to the Eclipse-Plugins Info site to find plugins.  Many of the plugins listed there will have some problem with Eclipse 3.0, but now that Eclipse 3.0 is out, updates are coming at a fast pace already.

Eclipse 3.0 is NOT released yet

I don't know where the mix up got started but numberous websites are announcing the release of Eclipse 3.0 already.  Note that the latest version is Eclipse 3.0 RC3.  The final version will be released on June 28 or so.

BTW, I noticed that Eclipse site now has links to BitTorrent seeds for Eclipse releases.  That should come in handy at the end of this month.

Update:

Just one day after I said Eclipse 3.0 final is not released yet, they released it ahead of schedule!  I am not sure whether this is good news or bad news since RC3 was still buggy and reporting problems here and there without much explanation.  Did they fix all the bugs in one week?  Unlikely.  And the next bug fix release (3.0.1) is not scheduled until September.

My guess is that schedule of some commercial products that depended on Eclipse 3.0 might have pinched Eclipse team's schedule.  Too bad.  I would have been happy with addition month of test.

BTW, forget about downloading it until later.  My own download session is estimated to take 16 hours to completion and BitTorrent seed site doesn't have 3.0 final available.

Update 2:

I have used Eclipse 3.0 final version for 8 hours straight now and it looks pretty solid.  Search complaining in out of sync projects is annoying but I haven't figured out how to turn it off yet.

WARNING #1: Regardless of which version of Eclipse you used before, start with a clean workspace.  Old workspace configuration will confuse some plugins.  Sysdeo Tomcat Plugin was acting erratic until I did that.  For example, Tomcat would not work properly on restart without restarting Eclipse as well.  Even then the pages would sometimes appear blank.  I wasted 3 hours trying different Eclipse/Tomcat/Sysdeo settings to get it working and ended up cursing softly (everyone was asleep) and lucked out with a desperate guess.

WARNING #2: JSP files will not be added as ASCII into CVS repositories unless you specifically add it to the list of known file types.  Look under Team > CVS section of the preference dialog.

Have fun.

Tomcat Crap

Urgh.  I just spent a few hours trying to figure out why JNDI JavaMail session stopped working.  Previously, I had Tomcat 5.0.26 beta installed and it was working just fine.  In an attempt to debug another problem, I peddled back to 5.0.25, which is the latest version without any beta tag, and found that I couldn't send e-mail out from an webapp.  Error message was rather bland so it took me a while to find the relevant bug report.  Guess what?  5.0.25 build left out some key classes related to JNDI JavaMail session support.  Heck, I think I'll go back to the beta version and keep my fingers crossed.