Subversion, Subversion – what client shall I pick?

Since I’m using Eclipse at home for development, it seemed logical to go with Subclipse or Subversive – two of the top three clients listed on the Subversion homepage.  I also tried TortoiseSVN the the other of the top three.  Below are my experiences with the three.  (I haven’t tried branching yet in any of them.)  All have had a release within the past month.  My comments for Subclipse and Subversive are largely from slightly earlier versions though.

Note: See If you tried Subversive before, it’s time to try it again for an update.

Subclipse 1.4.8 (released February 27, 2009)
Pros:

  • It seemed faster to checkout a large project with Subclipse than Subversive.  I can’t prove this as my internet connection varies, but I did notice this a few times.   Another person had the same observation though.
  • Has been around longer.

Cons:

  • No tag awareness!  When I want to commit a file, I need to think about copying the directory to the tags directory.  This is a mental jump as I’m really just thinking I want to create a version – not about how Subversion data is stored.  I also worry that it is too easy to accidentally create the version in the wrong place.  Why invite trouble?  The CVS Eclipse plugin just asked for the name of the tag.
  • Similarly, I have to think about where the tags are stored when comparing to a past version.
  • One common thing I do in Eclipse is awkward – I want to compare the contents of a file to tagged versions.  If I do “compare with revision” I see all the revision numbers and commit comments, but the tag column is blank.  If I do “compare with branch/tag”, I see all the tags, but can only select one to see the compare before starting the whole process again.  Also, you can only compare with branch/tag on a project level – which takes forever – at least over my internet connection.  As a clumsy workaround, we’ve been storing the tag name and revision number on our “release notes” wiki page.  This is an extra manual step that I feel should be unnecessary.  If the tool would just show the tag in the “compare with revision” view like Eclipse does, it would be perfect.
  • The proposal to become an Eclipse project has been withdrawn.

How long I used before switching
A few months.  It wasn’t until the project got into the tagging phase when the tag awareness feature became problematic.

Subversive 0.7.7 (release February 24, 2009)
Pros:

  • Can compare file with “working copy” (last checked out) without connecting to network
  • Since November 2007, has been an incubator project on eclipse.org.  This reset the version number which is why .7 is newer than 1.0/1.1 on polarion.org.

Cons:

  • Installing requires two parts.  The connectors are a separate install for licensing purposes.
  • As in Subclipse, I want to compare the contents of a file to tagged versions.  Using “compare with revision” is worse than in Subclipse.  it doesn’t attempt to show the tags.  More importantly, you must pick which revision you want to compare to, wait a while, view it and then repeat the entire process to pick another revision.  Not nearly as easy to use as the Eclipse version.  (If you think to open the SVN history view first, you get the Eclipse/Subclipse based view where you see them all at once.  It still takes forever though for large projects as it is seeing what else changed in that revision.  Turning off “deep copy” didn’t help matters.)  I didn’t try compare to with branch/tag because I didn’t see the option.

How long I used before switching
I started with Subversive.  After a few months a switched to Subclipse.  Then I switched back to Subversive where I have been since December.

I wasn’t thrilled with either of these so I then tried a standalone client. Tortoise SVN 1.5.9 (released February 27, 2009)
Pros:

  • Checking out one project wasn’t hard.
  • I like the GUI – very intuitive.
  • Committing was simple from Windows.
  • A very cool graphical release view for tags and branching.
  • I really like the log viewer letting you filter by date and or message.  It makes it easy to find out which version you want to compare with.

Cons:

  • It’s not in the IDE.  If not using an IDE, this isn’t a problem of course.
  • Windows only.
  • To tag a project, you need to be aware of the directory structure.  (See my comments about Subclipse for why this scares me.)  There is a graphical explorer to find the tags directory.

How long I used before switching
I just tried it for a few days.  I really wanted an Eclipse based plugin – was just looking to see if this was better.  If I wasn’t using Eclipse, this would be fine.

Conclusion

Both Subclipse and Subversion are usable Eclipse plugins for Subversion.  I prefer Subversive a bit and am going with that at home.  The main reason being tag awareness (I tend to deploy/tag on a weekday evening when I am tired and more likely to mess things up.)  I am keeping TortoiseSVN on my machine for the non-Java code checkins I need to do.  Note that you do have to pick one or the other.    You can’t point to both Tortoise and an Eclipse plugin for the same directory.  As a result, the last week of development on my home computer for Javaranch looked like:

  1. Sunday – Do a bit of Java development in JForum project using Eclipse.  Check out/commit using Subversive.
  2. Monday night – Generate the book promotion materials in PickWinners project by updating the build.properties and running an Ant build script.  (I don’t check these in on Monday since they are so easy to regenerate if something happens to my computer over the course of the week.)
  3. Wednesday night – Production deployment.  I wanted to get in some changes that would make sending private messages to the winners a two click operation.  (It took six clicks for each winner last time it was my turn.)  Tag JForum project using Subversive.
  4. Friday night – Pick winners for book promotion copying winners from web page into one of the files generated on Monday.  Commit using TortoiseSVN.  I like that I didn’t need to open Eclipse on Friday – picking winners is now a web page and the commit happened in Windows.

Many weeks I do less Subversion work at home.  It so happens last week was representative of the breadth of SVN operations I do.  I liked the split between Subversive for JForum (Java development) vs TortoiseSVN for PickWinners (Ant build and text files) and plan to continue that way. I’ll be interested to hear what my co-promotion coordinator uses to commit when it is his turn.  I’m not overly thrilled with either Subversion Eclipse plugin.  I’m thinking of pulling in the JForum project into another directory in Tortoise to use it for file comparison too!

This analysis isn’t so useful for recommending a tool in a corporate scenario where network connections are more reliable and projects are huge.  My suspicion is that Subclipse is better in that environment.  Especially if the majority of tagging operations are done through an automated build.

Why JDBC + JSP = Bad

Over years of moderating at The JavaRanch, I’ve seen one type of question spring up on a weekly basis: that asked by people who need help with JDBC code inside of Java Server Pages (JSPs). As much as we may want to help this individual fix their particular problem, the overriding thought of “STOP WHAT YOU’RE DOING” often prevents us from doing so. The purpose of this post is to explain why putting JDBC code inside a JSP file is akin to shooting yourself in the foot. With a shotgun. While not wearing shoes.

Don't use JDBC inside of JSP pages

1. You cannot reuse the code
First and foremost is the issue of code reusability. While importing java classes is quite common, importing code from a JSP is not. While you can write JSP functions, although I never recommend doing so for reasons I won’t get into now, you’re basically writing code that you cannot be used anywhere else, particularly in non-JSP java classes. The most common counter response to this is “Well, I don’t need to use it anywhere else”. Yes, you do. Whether its just reusing code for making the connection to database or the code for performing a query and reading the results, it will be used again at some point in the future in a way you have not thought of yet. Unless you are being paid by the line and prefer this sort of thing, it’s a bad move, and I guarantee your code base will be much larger than someone who put all their JDBC code into normal Java classes. Larger code base means more difficulty to maintain and more headaches for you down the road.

2. You are mixing business logic with the presentation layer
Probably the most overlooked issue for inexperienced developers is the fact that you’re mixing the business/data layers with the presentation layer. I’ll put it another way, if your boss comes in one morning and says we’re throwing out the JSP front end and replacing it with a web service, Java Swing, Flash, or some other interface, there is virtually no way for you to reuse the database code without going through every line of every JSP file by hand. If the database code had been placed in plain java files, then you would have a path for packaging the JDBC code into a single JAR and making it available as a service to a different front-end client such as a web service, Flash, etc.

In enterprise development, the presentation JSP layer and the database are often separated by multiple layers of indirection such as described by the commonly used three-tier architecture pattern. Those who are just starting out programming often do not know why mixing these layers is bad, but I promise you if you stay with software development you’ll understand one day.

3. But it’s just this once!
Often times, JDBC code enters JSPs by developer lying to themselves saying “Well, it’s just this once” or “I just need to test something”. Instead of being removed when the developer is done ‘testing’, the code often persists for a long time afterward. Furthermore, putting your JDBC code inside of reusable Java classes makes testing go faster! Spending 10 minutes setting up a single reusable Java JDBC class will save you hours down the road. Then, if you want to test more than one JSP page with JDBC logic, you already have your Java class file to start with. Proponents of test-driven development tend to understand this better than anyone.

4. It’s really hard to maintain
Code maintenance is another topic that new developers do not fully appreciate since they have not spent years maintaining the same code base. Unless you write the most beautiful JDBC code imaginable, its very difficult to read through huge JSP files looking for bugs and/or making enhancements. It’s a lot easier if all the JDBC access is restricted to a set of files much smaller in size than the JSP code base.

5. It’s a really bad practice
If after reading this article you still do not fully understand why you should not put JDBC code inside of JSPs, let me simplify the issue by saying “Just Don’t Do It”. Whether or not developers understand the reasons against doing so is not as important as stopping them from doing so in the first place. In short, you create code someone else (possibly yourself) will have the misfortune of maintaining down the road.

Windows Vista: Great features for Power Users

Disclaimer: I am an avid Mac enthusiast, but as a software developer I don’t have luxury of switching over to Mac completely, therefore my primary computer is still Windows based. This article is not meant to promote Microsoft, Windows, nor Vista, but merely to share my thoughts after installing Vista as a highly technical user.

Recently my computer died and I was forced to upgrade, triggering a re-installation of Windows. I decided to take a shot at running Vista 64, primarily for the ability to run > 3 GB of RAM that all 32bit systems are limited to. I found a lot of features in Vista that I believe “Power Users” like myself would very much enjoy.

Windows Vista

1. Better naming conventions: No more “My …”

One of nicest features is the naming conventions finally make sense. Compare this folder name in XP for Documents:
C:\Documents and Settings\Bob\My Documents
versus this one found in Vista:
C:\Users\Bob\Documents
I’m pleased to finally see some intelligence in Window’s naming conventions. Similar folders such as “My Music” have also been update. Furthermore, some folders, which used to be sub-folders of “My Documents” have been moved up a level to User’s home folder, making for a much cleaner interface.

2. Easy to customize Special Folders
If you’re like me, you probably have a boot harddrive separate from your data harddrive(s), this way if you lose your OS, your data drive (and associated backups) are still safe. Previously, in order to move your Special windows folders such as “My Documents” to a different drive, you had to either download/use TweakUI or perform a registry hack such as changing it to:
D:\Users\Bob\Documents
I’m happy to report that the ability to change a special folder’s location is built into Vista and much easier to access. You just right click on the special folder and you can specify its location. Also, for those who often used TweakUI to change this, you no longer have to navigate the GUI-based folder selector, you can just type or copy & paste your new folder path.

3. Start Menu “Run” now default
In XP, I spent most of my days opening the “Run” command to load dozens if not hundreds of programs a day. Why? Well, I’m way faster on a keyboard than a mouse. In Vista, as soon as you open the start menu you can start typing your command as if you had also opened the run dialogue. This is a huge advantage for people who over-used the Run command in XP. The only disadvantage I’ve found is if I’m trying to open a harddrive by typing “C:”, finds other applications such as Windows Calender. I can type “C:\” but I have to wait 1-2 seconds before hitting enter for it to work properly.

4. Services now listed in Task Manager
One thing that always bothered me about XP was that Services (services.msc if you’re typing it in) was separate from everything else. In Vista, there’s a new tab in the Task Manager with Services and their statuses. A marked improvement to me.

5. Installation was simple
After running Windows install of every OS ever made, I will say the Vista installation was the simplest with very few prompts for me to enter info. I’m not sure if that’s a great thing, though, since I had to do a lot of configuration afterward, but I appreciate the attempt by Microsoft to streamline installation process.

6. Forced Restarts
Sometimes when I’d go to restart or kill a program in XP, the computer would pause and/or come with a message such as “Waiting for X to quit…” followed by a long pause. If I did nothing, I could be waiting 1-2 minutes before Windows restarted. In Vista, restarts are forced which means even if the prompts come up Windows will bypass them quickly and help you to shutdown ASAP.

7. Aero is mostly good
A lot of the lawsuits/complaints about Vista revolve around people with integrated motherboard graphics cards on budget computers complaining they can’t run Aero. Fortunately, I have a nice video card so I don’t really have that problem. Aero is a decent Windows graphical enhancement, not as pretty nor straight-forward as Apple’s interface, but better than I expected. For example, in Mac OSX when you open a program in the task bar, you get a nice solid genie effect of the application popping up from the dock. In Windows, there are a lot of effects that make less sense such as when you open a new window, it starts small then grows outward from the center. While most graphics effects aren’t really supposed to do anything other than make you feel better, I don’t really understand the point of that one.

The only thing I truly didn’t like in Aero was the 3D switch between open windows; it gave me a headache. I’ll stick with the normal ALT-Tab thank you very much.

Things I did not like…
Vista’s not perfect and there are some things I did not like:
1. UAC is very, very annoying. During post-installation setup I got prompted every 2 seconds. You can turn it off though.
2. No built-in Internet Checkers… what will I do with my spare time?
3. Some programs have trouble installing although that’s be to expected with the slow crawl of 64bit OS’s over the last 10 years. Even Linux 64 users still rely on a lot of 32bit programs.
4. Sidebar is lame. It’s a poor attempt to copy Apple’s Dashboard application. I really prefer the one-click that drops the Apple’s Dashboard to the center of the screen, rather than hanging around all of the time on the side. Also, its buggy with many of the applications I downloaded crashing/broken. Definitely, a cheap knockoff in need of better plug-ins/support.

Conclusion
Overall, I’m pleased with the architectural changes Microsoft made in Vista. Would I recommend Vista to friends? Possibly, although definitely not the 64bit version. Most of my most serious problems were related to applications that refused to install on a 64bit OS. This isn’t really Window’s fault, though, the community as a whole should have crossed over to 64bit years ago, but somehow missed its target leading to the vast majority of people still running 32bit OS’s. I can’t wait until PC manufacturers start selling computers with 4-8GBs of RAM and 32-bit OS’s.

Other than that, I had no crashes, no BSOD’s, and aside from a lot of annoying UAC warnings and 64bit application incompatibilities, everything worked perfectly. For the most part, I was able to find 64bit versions or 32bit workarounds for the applications that would not install the first time.