Monday, December 31, 2007

How I sped myself up in 07

I love reading life hacker and other tips to improve myself. I am always looking for another tip that I can add to my arsenal to make something that I do faster, easier, or not necessary. In 2007 I have fully migrated myself to GMail. There are some good pluses, and some things that I don't like. I have read a lot about the different plug-ins for GMail and GTD but I have found them all to be slow, so I have kind of build my own GMail GTD folder system, without the plugins. As long as I'm consistent it's fine. I also use Google Calendar and share some calendars with others to prevent duplicate entries. I have fully implemented GTD into my life, and do pretty well with it. I still have more trouble at home than at work, because I have a harder time controlling the inbox items from my wife, but for the most part I am doing well with keeping myself organized and actually getting things done, which is the purpose.

One of the biggest things I have done though is to migrate almost completely away from windows desktop icons, or even quick launch icons, into slickrun. With a quick CTRL+M and a single work I can launch any of the applications that I use. I also have several folder shortcuts setup here. This makes it very fast for me to open new programs. Windows is nice for some things, but it really sucks at launching new applications. Just clicking on the start menu can cause my computer to freeze for 10-15 seconds, which when I'm trying to work seems like even longer. I like the command line because it's fast and I have a good memory so I don't have any problem remembering the launch keywords, especially since I chose them. More importantly though MagicWords are auto-complete so as soon as the word is unique I can hit enter and get moving on what I want to. Windows does excel in things like multi-selecting items in a folder view, and selecting an odd set of files such as those that CTRL+mouse clicking selects. Another thing that windows is awesome at is the drag and drop of data from one application to another and having them both understand how to interpret that data.

Looking ahead to 2008, I'm thinking of adding scripting languages like Ruby. There are so many new possibilities out there and I am excited to jump in and learn something new that can help me.

Monday, December 17, 2007

Is it a Story Card or is it a Bug?

I continue to participate in many discussions about whether a change is a bug to an existing card or if it should be tracked as a new card. Now that the third major release of our project there are some things that have come back to cause trouble.

In my opinion it gets to testing. If the change violates an acceptance test, then it's a bug. If the change is new functionality or a situation that had not been thought of, then a new acceptance test needs to be created. This can either be added to an existing story or a new story can be created for it.

The problem that we have faced is that new situations that aren't even hinted to in a story are discovered later, they happen to be not a big change, so they get put into the system as a bug. No acceptance test is created for them, and they are fixed. Weeks later, during testing, we get a question, "Is this supposed to work like this?" Yes, it is because of a bug that was entered. That's the problem. There is no tracked acceptance test anywhere that indicates the correct behavior of the system now. A new tester would be at a complete loss if he had to walk into this project, and the tester that has been with us since the beginning will forget things about the way the system works. Too many situations that require an acceptance test have not been documented, causing the same questions to be raised over and over again.

It seems almost as if this situation has created an us vs. them mentality between the developers and the tester. A bug by the tester means a failure to program the story correctly, while a new card is an admission of failure to correctly identify requirements by our tester. Both situations are true though, no matter the method used to capture the data. I push for cards not because I think the problem is not mine, but because it more accurately represents the testing status and reason for changes in the application. When a new tester walks into the project he should be able to look at the acceptance tests for all cards and perform a full regression test of the system. There should be no need to go through the hundreds of bugs and identify which of those actually caused a change to accepted behavior.

After a while, the application working the way it's supposed to is not going to be enough. If it is no longer properly documented why it's working that way, then maintenance of the application from both a development and testing aspect become a major problem.

Tuesday, September 11, 2007

Off by one

I hate being off by one. It happens a lot with loops and I had it happen again today.

I had

for(int i=0; i < payments.length-1; i++)

length is not zero based so I need to loop from 0 to length not inclusive. However I was one short.

The fix was simple.

for(int i=0; i < payments.length; i++)

Tuesday, August 28, 2007

Learning the hard way

Sometimes learning a simple well known lesson has to happen the hard way. That happened to me last week. My project (the one I'm part of a team for) was just about done and ready to deploy when an odd error that's never occurred before popped up. A user couldn't save a payment for the total amount due. That's a big deal.

I started looking into the issue and found that it was a pretty standard issue with using a double in Java to hold monetary values. So I thought, a quick find and replace would take care of it, but it didn't.

BigDecimal is an object and needs to be treated like an object. It also does not have the + operator implemented, or the comparison operators. So it was a lot more than just replacing all instances of Double with BigDecimal. To further compound the problem I was using double in many places and I had to convert all of those to BigDecimal as well. Finally the constructor for BigDecimal can take a double and all of my unit tests were written as
BigDecimal test = new BigDecimal(11.11);

However Java treats that as a double before putting it into the BigDecimal and that was causing the exact same floating point errors I had before. I had to change every one of my tests to use the String Constructor of
BigDecimal test = new BigDecimal("11.11");

All in all I modified about a thousand lines of code over two days because I didn't know ahead of time that I should have been using BigDecimal for money. This is a lesson I've learned and won't forget for the next time.

Wednesday, June 20, 2007

Are Microsoft users dumb?

One of the emails I get from Microsoft had this in it.
Featured tip for Windows XP

Set your desktop PC background to a solid color
Tired of making decisions? If you're not interested in choosing a background picture that "reflects" you, don't put yourself through it--just pick a color for your background. Colors are easy.

1. Right-click the desktop and click Properties.
2. Click the Desktop tab in the dialog box and click None for your background.
3. Pick a color from the Color button to the right and click OK.

Featured tip is courtesy of the book Windows XP Killer Tips by Kleber Stephenson.

Do they really think that their users are so dumb or indecisive that they can't decide on a background picture that reflects who they are? Granted I don't use a background picture all the time, but it has nothing to do with me being indecisive, it has to do with the fact that the desktop icons are easier to find with nothing in their way. This has become less of an issue now that I use the quick launch bar, the Desktop sidebar, and slickrun. But still, a better suggestion would have been to make it easier to find your icons use a plain background, rather than insulting the largest base of computer users. What idiot editor let this out?

Friday, June 01, 2007

Strange Agile link

I'm almost finished reading "Practices of an Agile Developer". I flipped ahead to the Appendix to checkout the links section and there is a strange link to the "Tragedy on the Somme: A Second Balaclava". I don't know what this has to do with Agile, or how it made it through editing. Maybe it is like an easter egg in software, only hidden within the Appendix. Maybe one of the authors thought it would be funny to list it as an important resource.

Anyway, if you are interested in the battle, I hope you read it, if you are interested in Agile though, I hope you go to sites that are more informative on that topic.

Tuesday, May 15, 2007

Yahoo UI Menu issue

I've been playing with the Yahoo UI Menu for the past 3 days. My objective is to have a main menu item created that when clicked will call an Ajax method that builds the first layer of menu items. This works and builds the menu, but they are not clickable. If I get a solution, it will definitely be worth posting.

Monday, May 14, 2007

Yahoo UI

I've been using the Yahoo UI in my latest application. This is a really cool tool. Including it is easy, and using it is just about as easy. Yahoo has done a really bang-up job of creating a tool with good examples. There have been some quirks with getting it to work in Portal, and I wish there were a few more examples of how to do some things with the controls, but in general they are great. Using the Yahoo UI has given the application a consistent feel for not a lot of cost.

I know, it sounds like a plug for Yahoo UI, but this really just the praise that I have for the tool.

Wednesday, May 02, 2007

Agile is like driving

As I ran to the store at lunch today, it occured to me that iterative development is a lot like driving.

When I first get into the car it's pointed in the direction that I want to go, but there are lots of variables that make that change. I know what my destination is, but people can be walking, there are other cars on the road, some streets can even be under construction. The constant adjustments that are made to drive safely are the iterations. The closer together these iterations are with driving the better. Waiting 5 minutes to open your eyes and check for any changes will probably cause an accident.

Iterations within project development are the same, they need to be small enough that you can prevent accidents before they occur. In my current project we are using 1 week iterations. I have only used 2 week iterations in the past and I was skeptical. However, now that I'm doing it, I like the one week iteration. We have daily feedback on our status, weekly feedback on the development that was expected, and we can adjust our schedule according to changes and unforeseen issues.

Monday, April 23, 2007

Java difficulty

I think I know why I have been having a hard time learning Java. Every other time I've tried learning a new language I've had a ton of ideas come flying into my head of neat programs to write using the new language. I learn most of the things that I need to know figuring out how to implement my little pet projects. Java however has been a different beast. I use it because that's what I need to use at work, but for my own personal use, I haven't found a single project to try writing in Java.

I think my next big leap in Java knowledge will happen when I finally come up with a project to write for fun.

Thursday, April 19, 2007

Java plus

I have been busy the past few weeks working on a new project at work. It's kept me away from posting very much because the stress of this project has carried over into my home life.

However, I have been using some new technologies for me, and I will try to post some of the things that I've learned in the near future.

Things that I've used in the past week are:
1. OJB
2. Java Web Services
3. Websphere Portlet
4. Some kind of mock object to help test the classes.
5. A tag library in the portlet.

Most of these I don't even understand what it is that I'm doing yet, I'm still just copying the same kind of things that I see being done in other places, but I'm getting closer to understanding when it is that I need to do one of those things, which is a big step in understanding how to use them. I still have a ton to learn, but there is more coming.

Thursday, April 05, 2007

A c# coding annoyance

One thing that's been annoying me a lot recently is the block comment for c#. Sure it's nice and easy to highlight everything and use the shortcut ctrl+k, ctrl+c, but then the whack whack is put all the way on the left. If a curly brace changes after that then the autoformatting tabs it over to put the whacks in the position within the block of code.

For example

public void DoSometing()
if( test() )
...Code goes here.

When commented out it looks like this.
public void DoSometing()
if( test() )
// if(true)
// {
// ...Code goes here.
// }

After adding some code it looks like this.
public void DoSometing()
if( test() )
// if(true)
// {
// ...Code goes here.
// }
... addidional code goes here.

This becomes annoying because the code that is commented gets pushed further to the right. I would much rather that the autoformatter leave left justified comments left justified. It doesn't have to be smart about where the spacing falls into line. If the block is uncommented, then the code can be repositioned to fit correctly. Any comment that is not completely left justified could be formatted, but it doesn't have to format the left justified comments.

Thursday, March 01, 2007

Streaming Files

I recently was working on a project where I wanted to have the desktop open a file that was on the server. However, the desktop user does not have access to the server directly. In order to do this I had to stream the file to the browser.

First I had to create a servlet
public class DocumentViewer extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {

Then I have to implement the method doGet to handle the http processing.

protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

DocumentFileTO documentFile=fileDao.getDocumentFile(id);
InputStream fileStream=documentFile.getFileContents();
BufferedOutputStream outBuffer=new BufferedOutputStream(resp.getOutputStream());

int c=0;

There are a few more methods that were very key in this.

public InputStream getFileContents(){
byte[] _fileContents;
try {
File file=new File(this.getPath()); // Path has already been set.
FileInputStream fileStream=new FileInputStream(file);
ByteArrayOutputStream byteOut=new ByteArrayOutputStream();
int c=0;
return new ByteArrayInputStream(_fileContents);
} catch (Throwable e) {
throw new RuntimeException("Unable to open file " + this.getName() + ": " + e.getMessage(),e); // Name has already been set.

Finally, there were two very important things that I had to learn.
resp.setContentType needs to hold the MIME-Type information for the browser to understand what it is getting. I found that there is a built-in Java library that will provide this information.javax.activation.MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType()
It takes a filename with extension as the parameter. The function just strips the extension and finds known MIME information for that extension. If you are using a custom extension you will need to add your own records to the FileMap, which is possible. I did not test how extensive the known filet ypes are because I only needed it for a total of 5 or 6 very common types, and they worked.

And resp.setHeader had to have attachment; in the call. Without attachment the file was trying to open in the browser, which for me was opening everything in QuickTime. Having attachment in the call set the file to open on the desktop using the users default application for the file type.

I learned a lot on this project. Streaming in Java, using a servlet to handle a request instead of a JSP page (this was new to me), and a little about the header information for streaming files. However, once it's done the code to perform this feature doesn't look nearly as impressive as the amount of time it took me to research the functionality to make it all work.

Monday, February 26, 2007

log4j and Websphere Portal

After 3 weeks of my programs not working I was pointed in the right direction by a co-worker. it turns out that for log4j to work properly on my local server, I needed to have the class loader set to PARENT_LAST. I had seen something about this online once, but didn't know what it was talking about.

In my server settings there is a place that adentifies the class loaders for the EAR and WAR files that are in it. These need to be set to PARENT_LAST in order for log4j to work properly.

If using a websphere application (non-portal), this configuration is in the web.xml file. Still everything has to be set to PARENT_LAST in order for it to work.

Apparently having it set to PARENT_FIRST is useful in a live environment because the admin can change the logging setting without redeploying and get additional information from the application, it goes to some general log and not the log that log4j specifies in the properties file, but it's still useful to be able to make that change without redeploying.

Redeploying web apps in order to change a configuration is another annoyance of Java I have learned about. Since an exe is not deployed, but instead a war file (a zip file by another name). I figured we could just modify the contents. But a web server loads the war file into memory one time, and it stays there until the server restarts or that component is shut down or redeployed. In order to make a change the application needs to be redeployed basically. Thus any changes to the WAR file would be useless. I am a bit confused as to the benefit of having so many properties files and xml files on something that cannot be easily changed at runtime however, when the end result is the same as having all of the values hard coded.

Thursday, February 15, 2007

C# internal Setter

I just read a great blog about having different access modifiers for the get and set methods of a variable.

In order to have different levels you just add the access modifier to the set method.

public string Description {
get { return description; }
internal set { description = value; }

This is awesome. I've had many times when I wanted to restrict the setter to my local class, so there is a controlled validation before setting, but not allow any external class to set the value directly.

Tuesday, February 13, 2007

Finally new posts coming

I've been swamped with learning new things lately, I still don't know them, but I'm going to probably have some growing pains posts coming about the things I'm going through. ANT scripts were a killer for me this past week, I'm trying to learn more about them and post soon.

Thursday, February 01, 2007

Disk Defrag Pains

I was trying to install a Websphere a while ago, and after it failed 3 times another developer told me to defrag my hard drive before trying again because it would help. I didn't think it would, but he has run the install several times, and mine had failed so I took a chance.

I have 2 GB of RAM installed and had to defrag my 50 GB hard drive. It took several hours, and was painful, because the process never used more than 32 MB of RAM. What's the purpose of not taking advantage of the memory space available? It is frustrating that the built-in defragger practically froze my computer while only showing a 5% CPU usage and 32 MB of RAM.

Please take advantage of the resources that are provided with bigger and faster hard drives. I thought that maybe there would be some good tools on the web for doing this faster, but after researching I really haven't found anything that claims to be any better than the built-in tool.

If anyone knows of a better way to defrag than the built-in Windows tool, please let me know.

Wednesday, January 17, 2007

A cool new tool

Ok, new is a relative term. This is a cool new tool for me that I've been able to really use to my advantage recently. If you haven't heard of SlickRun you should go and check it out. It's a floating run window basically, but instead of running like normal, you have the ability to create keyword shortcuts. I can now open about 30 applications without having to move my hands away from my keyboard to use the mouse. Take advantage of the shortcuts that are available to you. I love this already.

Wednesday, January 10, 2007

Google Sidebar vs Desktop Sidebar

This post has been a long time coming. I had used Desktop sidebar for a while, then switched to Google Sidebar. There are different things that I like about each one. Both have a lot of plugins available, Desktop sidebar has more plugins than Google, strangely. Also the plugins for DS seem to be more windows specific, while the GS is more Linux specific. I have a small subset of plugins that I used, and I'll compare them.

1. Appearance
The DS can be skinned to be a lot of different colors and match pretty much any scheme imaginable on the desktop. I've switched my scheme several times and they are all very sharp.

GS not skinnable, you can change the font to larger, but that's not very useful.
Winner DS.

2. Location
DS can be docked left or right, or be floating, It could also have auto-hide turned on, which allows it to slide off the screen until the mouse moves over the edge of the screen. DS can also change monitors, which is great for anyone (like me) working on more than one monitor. I can move it to the right hand side of my second monitor. DS can also be made to be partially or completely transparent. The transparency annoys my to no end, but some users may really like that feature.

GS can be doced right or left and have aut0-hide turned on. None of the other options are available.
Winner DS

3. Clock
A clock is a small feature, it's one of the first apps that we used to write when learning C. A cool feature was being able to put a clock on the application we were using to make it easy for anyone to know what time it is. On both apps, the clock still seems to be a prominent feature.

DS has a clocks that are either analog or digital. The analog clocks are awesome. No matter what kind of clock displays when the mouse hovers over the clock a window pops up with todays date, and a 2 month calendar view (this and next) with today hi-lighted.

GS has several clock options also, with digital and analog. An option is to have the calendar visible. GS does not have a popup window, everything must be visible in the Sidebar pane, which is very limiting and makes the clock feature almost useless. I ended up turning it off on mine because I couldn't read it.

Winner - DS

4. Weather
I'm not a big weather buff. Some people I know like weather apps to pop up and tell them the current weather every 30 minutes. I want to see the forecast, and know the current temp before I go out, that's it.

DS has a weather panel that uses the Weather Channel and can be configured to my own town. I It shows me the current temp, hovering over the panel pops up a window with a 5 day forecast and links into

GS has a weather panel that displays today and tomorrow's low, high and the current temp. Clicking on it will do a Google search for weather in the configured city.

Winner - Even

5. Music
I don't have lots of music on my computer, but I sit with my headphones on most of the day. I like to be able to quickly change the music based on my mood.

DS has a panel that works with Windows Media Player. I love this. I know and am comfortable with it. It has a huge benefit though. There is a button on the panel that will display Windows Media Player and hide it. It does not minimize it to the taskbar, it hides it completely. With normally having 15-30 open windows, My taskbar space is important to me, and this is a huge benefit. The standard play, pause, stop, last and next buttons are available in the panel.

GS has several panels for music. One can play any song that you drag into it. I don't want to drag my music to a panel everytime I want to play it. I want it managed for me. The one that I use will play any music that has been indexed by Google Desktop, however, you have to add which artists you want to listen to, so I can't listen to an album at a time if the album is a compliation. Plus if I have more than one album by an artist, I have to listen to all of the artists music. It was very limiting. I did end up eventually getting a list of music that I could handle, but the tool was not what I was looking for.

Winner - DS

6. ToDo
DS has a ToDo panel that can take free form text and it's like having a quick list right in the sidebar. I love it for quick tasks. However, there is a problem and it does not save to the hard drive, so sometimes after restarting, the items that that I've added are completely gone and tasks that I had deleted are still there.

GS has a ToDo panel that works the same as DS, but I have never had a problem with it recovering after a shutdown or even a blue screen of death, which I have had on Windows XP.

Winner - GS

7. Quick Launch
DS has a quick launch panel which shows the same items that are in quick launch toolbar for Windows. It displays the icons and they can be reordered independently of their order in the windows quick launch.

GS has a quick launch panel which shows the same list. However, all icons tool tip text shows the filename.lnk. Making custom shortcut names useless. They are not in the same order as the windows quick launch, nor can they be reordered.

Winner - DS

8. Notes
DS has a free form text notes panel that works just like having notepad open, it's nice for small quick notes. It has had similar poblems as the ToDo list.

GS has a notes panel the same as DS. It does not have a problem saving the notes.

Winner - GS

Those are the features that I use consistently, there are two more that I did use from time to time, but I have found other tools that I like more.
9. Email.
DS has a panel that can display Outlook emails and popup a notification when a new mail comes. All folders are accessible through the panel and new mail can be written. Basically all of Outlooks navigation features have been put into the panel with the ability to open Outlook emails and compose them available. My favorite feature was the popup notification of the email with the sender, subject and first line of the email. However, since upgrading to Outlook 2003, I no longer need that because Outlook now has that feature available. Having it on in DS just shows me two popups which becomes annoying.

GS has the same feature for Outlook, plus it can show your GMail account as well. This is nice, but my GMail account is a personal account, and I'm using this at work, so I don't want my personal email distracting me from work.

Winner - GS, but for me Outlook works best now.

9. RSS
DS has several different options of plugins for RSS readers. Some are tied to specific sites, some are configurable. The configurable ones are nice, but don't allow you to mark things as read, so they continue to show up in the list even after you have read them.

GS has an RSS reader that shows you items as well. I did not test this at all because I have found other tools that work for me.

Winner - Even

For RSS I use Google Reader now for all of my RSS Feeds. In the past I have used Bloglines and Newsgator. I like Newsgator a lot and if you don't want to get a Google account then I suggest Newsgator. Google Reader has the same feel as GMail and can use tags on blog posts. I have only just started to use this to keep the posts that I want to be able to refer back to, but I love the interface and ease of use. For work related RSS Feeds I use Attensa, which is a plugin for Outlook. It's also free, which is another huge bonus.

Outcome: Desktop Sidebar: 5 - Google Sidebar: 2 - Tie: 2

Winner Desktop Sidebar.

Monday, January 08, 2007

Learning a new language

How do you go about learning a new language? I've had to do this several times and I have had the most luck with buying a book and immersing myself in the new language. I have to do it both at work and at home to really get into it though. After about a month of digging I've been able to feel comfortable supporting applications in the languages I've used, but not necessarily in making great design decisions.

Currently I'm learning Java. I've been reading "Thinking in Java" and trying to get through that. I've also got to learn JSF (Java Server Faces), Ajax, and IBM Websphere Portal. It feels like I'm trying to learn 8 languages at once, and even with all I'm reading about Java, I don't feel like I'm making a dent in what I don't know for my job right now. It's frustrating.