My thoughts as an enterprise Java developer.

Tuesday, November 21, 2006

Google Desktop had to be removed

Since my last post on Google Desktop I had 3 problems with it:
  1. Paused indexing prevents rename of directories
  2. Google Desktop appears to hang computer then using Remote Desktop (Terminal services)
  3. IT required that I remove it because of security issues.
:-(

Thursday, November 02, 2006

Search and replace across files

Some of my co-workers had their cvs login name changed so we had the problem where every directory checked out from cvs had a CVS subdirectory with a Root file in it that had the old username. The easy way was to delete all checkouts and checkout again but if that would cause the loss of data we needed a different solution.

I handled my machine by doing a Windows search for all Root files, adding them to a new project in Source Insight, then doing a search and replace but others don't have nice editors like that. My machine had over 10,000 Root files so manual processes were out of the question.

For those without a nice editor that can do a replace across files I came up with the following solution:
  1. Install UnxUtils and add the main directory to the path.
  2. Run:

    find . -name Root -print | sed "s/.*/copy & &.new \&\& sed \"s\/jstauffer\/jstauffe\/\" &.new > & \&\& del &.new/" > Root.bat

    Windows has find so I had to make sure that it used the correct find. Basically it finds all Root files, creates a command to copy that file, use sed to do the replace back to the original file, and delete the copy of the file.
  3. Run Root.bat
I know the same could have been achieved in Perl or even Java but is there anything else that would be as quick and easy (granted it isn't easy to understand)?

Tuesday, October 17, 2006

Dragging in UI and finishing with a quick movement

When the user drags an item to a location, slows movement, and then makes a quick movement right before finishing the drag, the user probably wanted the ending location to be the mouse location right before the quick movement. The user should be prompted for which target they want if the quick movement changed the target. With normal mice there probably isn't often a quick movement but I use a pen (an old version of the Intuos 6x8) for ergonomic reasons and I often have a quick movement as I let go of the button on the pen.

Friday, October 06, 2006

Google Desktop Rocks!

I was developing a new feature and needed to add a new column to the database. I didn't remember the exact syntax so I went to look for a sample on my computer. A few weeks ago I had installed Google Desktop (because I had done some searching using Windows search that took an hour!) so I thought I would give that a try. I knew the command started with alter table so I first typed that into the search. In less than a second it gave 6 results but the first result wasn't useful. So I added quotes around the search words and an instant later it showed 6 results and the first result was exactly what I wanted! I was quite surprised by how fast and easy that was! I even had to show it to my co-worker LaMoine.
Just for comparison we went through the steps of doing it the old way. I knew there was probably an example in a specific directory (5 levels deep) so I clicked on the button for Windows Explorer in the task bar and did 5 clicks to get to that directory. I then did a search for the same term (without the quotes) and it gave the same file as the first result.
It took over 25 seconds compared to under 10 seconds for Google Desktop! That savings in time would be significant in keeping me "in the zone" except that I was so surprised by how good it was that I had to show LaMoine and write this blog entry. Anyway the next time I have to search for something on my computer (when not in an editor) I will be using Google Desktop! (I have no ties to Google -- I am just a satisfied customer).

Friday, September 08, 2006

Why I like my job

Here are a few reasons (off of the top of my head) why I like my job:
  • Telecommuting one day per week (I wish I could do that more.)
  • Being a "guru" on a product.
  • Good team that is smart and willing to do any task to help.
  • Good compensation
  • 5 weeks of vacation
  • Minimal office politics
  • The company is profitable and growing quickly
  • The company is the biggest company in our area (or so they tell us :-) ).
  • We use a language that I like (Java if you couldn't guess :-) )
  • We use 3rd party libraries where appropriate.
  • Few meetings and very few useless meetings
  • We attempt to use best practices and improve things as much as possible while still balancing business needs (like creating new features for users).
For reference my title is Sr. Software Engineer and the products on which I work are web-based using J2EE.

My employer: "SPS Commerce is the leader in hosted Electronic Data Interchange (EDI) software. We offer a rapid, turn-key service to connect suppliers with their retail and distributor customers using tested and proven EDI connections and integration services."

I like my job so well that pretty much the only reason that I would be willing to switch would be if I could telecommute more and still have most of the things above.

What do you like about your job and what would it take for you to move to another job? The harder it be for another company to lure you the better you probably like your job!

Wednesday, August 30, 2006

How do you make money with open-source software?

You don't, you save money!

(Some companies do make money but many more companies could save money). More companies are concerned with using software than selling software. If users of software fund the open-source development of software then it will make economic sense for the software to be developed open-source.
If 50% of companies that buy commerical database systems instead used an open-source database and spent 25% of the savings promoting and advancing that open-source database then it would all work out well.
The one difficulty is getting the software customers organized to do this. It really helps if someone can jump start the project so that other companies can see the value.

Would you rather spend $100 for for Windows XP or get Ubuntu and spend $25 supporting it?

Tuesday, July 25, 2006

Definitions: Always and Never

Definitions:

Always – At least 10% of the time.

Never – Less than 90% of the time.

Friday, April 07, 2006

Iterating

I often see code like:
Iterator i = list.iterator();
while(i.hasNext()) {
...
}
but I write that (when Java 1.5 isn't available) as:
for(Iterator i = list.iterator();i.hasNext();) {
...
}
because

  • It shorter
  • It keeps i in a smaller scope
  • It reduces the chance of confusion. (Is i used outside the while? Where is i declared?)

I think code should be as simple to understand as possible so that I only have to make complex code to do complex things. What do you think? Which is better?

Thursday, March 09, 2006

Sorting algorithms


http://www.cs.rit.edu/~atk/Java/Sorting/sorting.html
shows four sorting algorithms and animations for each. It shows Bubble, Quick, Odd-Even Transposition, and Shear sorts. The last two are multi-processor sorts so I have 2 questions:

  1. Could Bubble and Quick sort be changed to multi-processor sorts? It seems that Quick Sort could be.

  2. How would they compare in time to the other multi-processor sorts? It would be especially interesting how Quick Sort would compare.

Wednesday, March 01, 2006

Don't return in a finally clause

The code below actually prints "yikes!"
If you return in a finally block then any Throwables that aren't caught (in a catch block that is part of the same try statement as the finally block) will be completely lost. The really bad part about this is that it looks so innocent. I can think of no reason to return in a finally clause. If nothing else, catch Throwable and return in that so it is obvious what is happening. Note this also applies to other things that transfer control (continue, throw, etc).


public class Test {

public static void main(String[] args) {
try {
doSomething();
System.out.println("yikes! don't program like this!");
} catch (RuntimeException e) {
System.out.println("got it.");
}
}

public static void doSomething() {
try {
//Normally you would have code that doesn't explicitly appear
//to throw exceptions so it would be harder to see the problem.
throw new RuntimeException();
} finally {
return;
}
}
}