Monday, February 4, 2013

How does a brogrammer become a programmer

A brogrammer is a type of programmer known for his sexist comments, macho brashness and frat-boy attitude.  A brogrammer is sort of the opposite of a nerd, in a bad way.

I am part-brogrammer 
While some would say that brogrammers aren't real, I see a little bit of brogrammer in me.  While I don't normally drink booze while I code nor do I make many sexist coments (as far as I know), I am guilty of suffering from one part of the brogrammer stereotype.  And worse yet, I think I picked up one of the worst brogrammer characteristics.  My attitude towards writing code is way too macho.  I think this is one of the worst brogrammer traits, because it will eventually make your final product worse.

Macho brogramming leads to bad software
So why is macho programming bad?   It leads to an over-estimation in a coder's ability.  I often promise to deliver something, and find myself short on time.  In order to finish on time, I'll have to work late and/or push out rushed code, which leads to buggy code.

Beyond the code you actually write, macho brogrammers like myself spend way too little time not writing code.  I have come to realize that good software developers spend a lot of time reading, asking questions and planning.  Writing code should come at the end of a lot of thought.  If you begin writing too early, chances are you haven't found the ideal design and you will either have to re-write code or live with poor design choices.

Putting the Pro back into Programmer
I think the way to stop being a macho brogrammer is pretty simple.  Here's what I came up with.
  1. Think first. Code later.
  2. Ask lots of questions.  

Saturday, February 2, 2013

Tips for using Google Web Toolkit

This post will be a set of notes with UI improvements.

Loading Image ...
If you are loading an image that may take some time to load, it would be nice to tell the user that something will appear.  One way to do this is to put some text into a panel first, and when the image is ready, display it to the user.
// Fill in the panel with some text.
Label loadingImgLabel = new Label("Image loading ...");
private VerticalPanel imagePanel = new VerticalPanel();
imagePanel.setHeight( "250px" );
imagePanel.add( loadingImgLabel );

// Make a async call to get the image you want
// When it is ready, replace the text with an image.
Image image = new Image();
image.setUrl( "location/of/img" );

imagePanel.clear( );
imagePanel.add( image );

Setting the width of the panel
If you want your widgets to fill up the page, set widths like this:
private VerticalPanel aPanel = new VerticalPanel();
aPanel.setWidth( "100%" );

How to write to and clear a Flextable
I was trying to clear rows from a flextable in the following way:
FlexTable flexTable = new FlexTable();
flexTable.setText( 0, 0, "some text to add in row 1, column 1" );

// This clear statement didn't remove the text from the table
flexTable.clear();
I realized that the clear command will only clear widgets.  Thus, in order to add and remove flextable rows, you need to do the following.
FlexTable flexTable = new FlexTable();
flexTable.setWidget( 0, 0 ,
new Label( "some text to add in row 1, column 1" ));
// Now, the text as widgets will be removed, as expected
flexTable.clear();
// Just to be extra safe, you can also do
flexTable.removeAllRows();

More to come later ...