My thoughts as an enterprise Java developer.
Friday, August 10, 2007
toString() cost
Do you assume that toString() on any given object has a low cost? I do. Is that assumption valid? If it has a high cost should that normally be changed? What are valid reasons to make a toString() method with a high cost?
Thursday, August 02, 2007
Dynamic/static language
What if a language allow both static and dynamic types. That might allow the best of both worlds. i.e.:
String str = "Hello";
var temp = str;
temp = 10;
1. Would that be possible?
2. Would that be beneficial?
String str = "Hello";
var temp = str;
temp = 10;
1. Would that be possible?
2. Would that be beneficial?
Wednesday, June 27, 2007
Debugger for *nix pipe commands
As I build *nix piped commands I find that I want to see the output of one stage to verify correctness before building the next stage but I don't want to re-run each stage. Does anyone know of a program that will help with that? It would keep the output of the last stage automatically to use for any new stages. I usually do this by sending the result of each command to a temporary file but it would be nice for a program to handle this.
Monday, June 25, 2007
Tuesday, May 22, 2007
Programming Trends
Friday, May 18, 2007
Telecommuting tips
I have been telecommutting 1-2 days/week for a few years so I present the following tips to those who want to telecommute:
- Practice communicating by email (especially when it is easier to talk in person about something) so you get better at writing emails that are complete and easy to understand.
- Practice doing as many normal activities on your telecommuting days as possible. Minimize "waiting until you get back to the office".
- Practice minimizing differences between your telecommuting and in-office days so that your telecommuting doesn't negatively affect the company.
For me #1 was the hardest to learn.
Monday, May 07, 2007
Method return values for null objects
Would it be useful to be able to provide method return value for null objects?
For a List the null return values might be:
get(int) : null
size() : 0
iterator() would be an empty iterator
That would allow the following code that has less null checks.
List items = null;
if(something) {
items = ...
}
for(int index = 0; index < items.size(); index++) {
Object obj = items.get(index);
}
For a List the null return values might be:
get(int) : null
size() : 0
iterator() would be an empty iterator
That would allow the following code that has less null checks.
List items = null;
if(something) {
items = ...
}
for(int index = 0; index < items.size(); index++) {
Object obj = items.get(index);
}
Friday, March 30, 2007
Automatic casts
Why can't the compiler automatically insert casts?
List list = new ArrayList();
list.add("one");
list.add("two");
for(Iterator i = list.iterator(); i.hasNext(); ) {
String item = i.next();//Automatic casts
System.out.println(item);
}
//Or using the new for construct:
for(String item : list) {
System.out.println(item);
}
http://weblogs.java.net/blog/emcmanus/archive/2007/03/getting_rid_of.html shows that the compiler can get really close. Why can't it go the rest of the way?
List list = new ArrayList();
list.add("one");
list.add("two");
for(Iterator i = list.iterator(); i.hasNext(); ) {
String item = i.next();//Automatic casts
System.out.println(item);
}
//Or using the new for construct:
for(String item : list) {
System.out.println(item);
}
http://weblogs.java.net/blog/emcmanus/archive/2007/03/getting_rid_of.html shows that the compiler can get really close. Why can't it go the rest of the way?
Friday, March 16, 2007
IDE freedom
One way that I evaluate a new IDE is by opening a file in a fresh install and determining how much I can do with that file. Obivously features that need to know about the other files in the project won't work. I recently tried to use NetBeans and JDeveloper to generate getters and setters. Neither would allow me to do that and one of them allowed me to choose that menu item but it just did nothing at all. Maybe creating a project would have helped but that should be needless. When an IDE "gets in the way" with what I want to do like that then it feels more like a straightjacket than a tool. I know that is a simplistic evaluation but when that test fails I wonder how constraining the rest of the IDE is.
Do you think that is a fair way to evaluate?
Do you think that is a fair way to evaluate?
Friday, February 23, 2007
Cygwin ssh and key files
I tried to use key files with Cygwin ssh (so I don't have to provide my password each time) but kept running into the following error:
To fix this I did the following:
It now works great (even in the normal Windows shell)!
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@The problem is that chmod wouldn't actually change the permissions so I couldn't get past this problem. When I searched on this I found refernces to turning StrictMode off but that didn't work for me can caused errors.
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '//turfclub/users/jstauffe/.ssh/id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: //turfclub/users/jstauffe/.ssh/id_rsa
To fix this I did the following:
- Started my bash shell
- mkdir /home
- mkdir /home/.ssh
- cp ~/.ssh/* /home/.ssh
- chmod 600 /home/.ssh/*
- mv ~/.ssh ~/.ssh.bak
- cd ~
- ln -s /home/.ssh
It now works great (even in the normal Windows shell)!
Wednesday, January 17, 2007
Automatic casting
Is there any downside or problem potential to change the Java compiler to automatically cast? In the example below the result of
I know that generics allow you to reduce casting but they do so at the expense of making declaration more difficult. To me, the benefit of generics is that they allow you to have the complier enforce more rules -- not they they reduce casting (but I haven't used them much so I am somewhat uninformed). This proposal would only reduce the amount of code to type, not move it to another place.
list.get(0) would automatically be casted to the type of the variable hi.
List list = new ArrayList();
list.add("hi");
String hi = list.get(0);
I know that generics allow you to reduce casting but they do so at the expense of making declaration more difficult. To me, the benefit of generics is that they allow you to have the complier enforce more rules -- not they they reduce casting (but I haven't used them much so I am somewhat uninformed). This proposal would only reduce the amount of code to type, not move it to another place.
Tuesday, January 16, 2007
Who has changed the most lines in cvs?
The following was done on a Windows machine with UnxUtils.
cvs annotate > annotate.txt
rem remove the portion before the name
sed "s/^[0-9. (]*//" annotate.txt > annotate2.txt
rem remove the portion after the name
sed "s/[ ].*$//" annotate2.txt > annotate3.txt
sort annotate3.txt > annotate4.txt
uniq -c annotate4.txt > annotate5.txt
Monday, January 15, 2007
Tip: Need to communicate between anonymous inner classes?
Here is a quick tip:
Do you have two anonymous inner classes that need to communicate? I had two anonymous inner classes that implemented Runnable and needed to communicate with a boolean value. Therefore I decided to make a boolean variable in the declaring method but in order for the inner class to access the variable it needs to be declared final. But that would prevent me from changing the variable! I needed a mutable Boolean. Instead of creating a MutableBoolean class I declared the variable as "
Background of why I needed this:
In an applet, I was saving data back to the server. In order to keep the UI responsive I of course do that in a separate Thread from the Event Distpatch Thread. When I save the data I first send then data and then read the response so the user only really needs to wait for the data to be sent. Therefore I have a timer that tells the user that they don't need to continue waiting after they have waited 30 seconds. But I don't need to pop that if the response is already read so I needed a way for the reader thread to tell the timer message Runnable that it was already done. I actually found a better solution: The reader thread can call stop on the Timer so that it is never run.
Do you have two anonymous inner classes that need to communicate? I had two anonymous inner classes that implemented Runnable and needed to communicate with a boolean value. Therefore I decided to make a boolean variable in the declaring method but in order for the inner class to access the variable it needs to be declared final. But that would prevent me from changing the variable! I needed a mutable Boolean. Instead of creating a MutableBoolean class I declared the variable as "
final boolean[] done = new boolean[]{false};" so that one thread could call "done[0] = true;" and the other thread could check "if(!done[0])". If there is a better pattern for this please tell me.Background of why I needed this:
In an applet, I was saving data back to the server. In order to keep the UI responsive I of course do that in a separate Thread from the Event Distpatch Thread. When I save the data I first send then data and then read the response so the user only really needs to wait for the data to be sent. Therefore I have a timer that tells the user that they don't need to continue waiting after they have waited 30 seconds. But I don't need to pop that if the response is already read so I needed a way for the reader thread to tell the timer message Runnable that it was already done. I actually found a better solution: The reader thread can call stop on the Timer so that it is never run.
Tuesday, November 21, 2006
Google Desktop had to be removed
Since my last post on Google Desktop I had 3 problems with it:
- Paused indexing prevents rename of directories
- Google Desktop appears to hang computer then using Remote Desktop (Terminal services)
- 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:
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:
- Install UnxUtils and add the main directory to the path.
- Run:
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.find . -name Root -print | sed "s/.*/copy & &.new \&\& sed \"s\/jstauffer\/jstauffe\/\" &.new > & \&\&amp;amp;amp; del &.new/" > Root.bat - Run
Root.bat
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
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).
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:
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!
- 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).
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?
(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.
Subscribe to:
Posts (Atom)