Tuesday, December 20, 2011

Eclipse Performance Tuning

This is an excellent article on Eclipse Performance Tuning.  The author references a lot of other good articles too.

I am running Eclipse on Linux with the IBM 1.6 JVM.  Performance is actually good for me, but eclipse increases the load on the box and other people suffer.

Friday, December 16, 2011


Software developers really need to get better at UI.  (I am working on getting better myself.)  Here's a UI Design Top Ten.

SQL Happiness

Hello SQLer's out there.

Here's a little nugget for you.  Use the join syntax.  Why?  Because it becomes super obvious what parts of the SQL is for a JOIN and what parts are for a filter.

Here's what I mean

select blah
from blah1 a, blah2 b, blah3 c, etc.
where a.field = b.field 
and a.other like 'ABC%'
and b.field = c.field

In a big SQL with more tables and more fields, you start to loose the distinction between join and filter parts of the SQL.

This is better:

select blah
from blah1 a 
inner join blah2 b on (a.field = b.field), 
inner join blah3 c on (b.field = c.field), etc.
where a.other like 'ABC%'

Don't you agree?

I made this post because I have a 20 line SQL with a filter clause hidden among the join clauses.  This is better practice.

Thursday, December 8, 2011

Wednesday, December 7, 2011

DB2 SQL Explorer

This is pretty easy to set up.


SQL Explorer is great.  Go look at the screen shots.  It's working really well so far for me.  You have to have the DB2 universal driver and set up the jar files and driver name, but that's all.  Then connect to your DB, create a project, save your SQL file and start cranking!

Be careful of your transactions!  (I always begin tran/rollback tran/commit train it's a good habit)

Follow up

I have since found that data tools for Eclipse is just as good if not better.  It will allow you to load, unload data from a table.  Pretty handy.  See also my SO question about loading data into db2 from eclipse.

Tuesday, December 6, 2011

Window XP Mode Speedup

I'm using Windows XP mode to do a project.  It's kind of a legacy project and I know all the tools will work well on XP.  XP Mode was running really slow, but I changed the Integration Features and increased the memory.  In Integration Features I turned off everything except for clipboard integration which is hard to live without.  Performance is much better.

Thursday, December 1, 2011

Wednesday, November 23, 2011

strace to the rescue

So today I feel like a haxor.

My coworker was having an issue with Eclipse/EGit (on linux) and it was a very cryptic error message.  So we ran an strace -p 1234 -p 1235 -p etc. -o strace.log -ff -q on his java process (not the eclipse process).  I tried a trace with -e trace=file, but we did not get much in the logs.  The full trace worked.  We searched for git in the logs and found that his .gitconfig file was missing the [user] tag at the top.  (After comparing to my .gitconfig file).  We added the [user] to the top of his file and we got past the error!  Yay!  He had created the file by himself according to some instructions that we are going to CHANGE.  LOL.

Here's a script to generate the tracer.sh command as seen above.  This is provided as is with no warranty.  Use/edit at your own risk.


if [[ -z "$1" ]]
echo "Call this script with the process ID of eclipse or java."

pidlist=`ls -1 /proc/$1/task | sed s/^/\ -p\ / | sed s/$/\ \\\\\\\\/`
strace_cmd="strace -e trace=file $pidlist
 -o strace.log -ff -q"
echo "strace_cmd is $strace_cmd"
echo "$strace_cmd" > tracer.sh

Tuesday, November 22, 2011

Monday, November 14, 2011

Thursday, November 10, 2011

Git rule of thumb

If you can't push, fetch and merge (or pull), then try again.
If you can't pull, try a commit!  (You might have an open commit/dirty files which are causing merge conflicts)

If that fails, go to gitref.org.

Strace to debug processes in Linux

Strace is an awesome debugging tool.  Vhokstad has an awesome blog post about different ways to use strace.

Exactly like in his post, I used strace on Eclipse and Java by PID but I only got a futex message back.  I know for a fact that more is happening...  I found out it is a threading issue.  Strace -p PID will trace the main thread by default.  Thanks caf and stackoverflow.

I'm going to use strace while starting the process instead.

Rambling post continues...

Using  strace -t -f -ff -d -o killed my session.  I wish I knew why.  I'm going to try to go back to strace -p PID and find the correct thread.

Friday, November 4, 2011

Eclipse is Awesome Again. (MySQL this time)

In half an hour I was able to download the Mysql JDBC database driver (login account to mysql required), put it on my Linux system, and then set up Data Source Explorer in Eclipse to connect to my test database.  You can drill down to tables and edit the data.  You can save or revert your edits at will!  Sweet!

I had to create a new MySQL user 2 of course using this:
Create User

I may need to get the SQL Exlporer plugin since I don't see a way to write and execute SQL with this, but it is an awesome start.

Wednesday, November 2, 2011

Monday, October 31, 2011

UNIX/Linux to Perl

I like this article from perlmonks.


It shows UNIX/Linux commands and their Perl equivalents.

Thursday, October 27, 2011

Behavior Driven Development

Last night I went down to Draker Laboratories on Pine St. for a presentation on Behavior Driven Development.  The presentation was by Pete Brown in affiliation with "Burlington Web Application Group (BWAG)".

The presentation was excellent and there was a lot of good participation and feedback.  Here are my main takeaways from the presentation.

There were really 2 main topics, test driven development (TDD) which seems to focus on automated unit tests and behavior driven development (BDD) which seems to focus more on automated functional/user tests.  Think of it as automatically testing agile user stories.  If you do TDD well, you are probably doing BDD also.

There are tons of benefits of both of these strategies, but the ones that I liked were how you can get much better decoupled code as a result.  Decoupled code is much easier to reuse.  Also if you create your functional tests first (before writing code), it helps you analyse your requirements.  Then write your unit tests.  Then write your code.  One obvious benefit is code with fewer bugs ;)

When writing code, FAIL the test first.  Then make it work.  Then refactor and repeat.  This is known as the Red, Green, Refactor cycle.

A product called Cucumber was highly recommended for BDD which is a tool that allows you to create user stories and acceptance tests (think agile) and automate the testing of these.  Cucumber works with most languages.  (You can use Jasmine for javascript).

Having said all this, QA starts with developers but definitely does not end there.  You still get a lot of value from real user testing and testing by subject matter experts (SMEs).

Pete mentioned a book called "Refactoring" which came highly recommended.

Another topic that was mentioned was "continuous" testing, which means the minute you change the code, the test is run, so you can get instant feedback.

Finally, Selenium was mentioned as an automated browser testing tool.

There is more I could say, but these are some of the highlights.

Monday, October 24, 2011

Git Amended Commit Issue

I ran into an issue with Eclipse and EGit.  I did an amended commit and tried to push upstream.  The push failed with a really generic error message.  Luckily the answer is really easy, thanks to RIP: pull first, then push your amended commit.

Wednesday, October 19, 2011

Git is Awesome

We started using git at work and I love it.  Specifically, we are using EGit with Eclipse.  I love how it does not operate a file at a time and how you can commit as much as you want, saving push to upstream for when you are ready to "share".  I'm still getting used to the lingo, push, fetch, pull, etc.

Wednesday, October 12, 2011

Dojo charting Tooltips

It took me a while to get the tooltips working on my chart.  There was no definitive answer anywhere.

What I found is that in dojo 1.6.1, you need to do the following:

  1. dojo.require("dojox.charting.action2d.Tooltip");
  2. chart.addSeries("seriesName", chartData, {plot : "default"}); // Here you have to make sure chartData is an array of objects like this [{y: 1234, tooltip: "Tooltip text 1"},{y: 2000, tooltip: "Tooltip text 2"}]
  3. tooltip = new dojox.charting.action2d.Tooltip(chart, "default");  // Where default is an already defined plot and chart is also already defined.
  4. chart.render(); // You MUST declare the tooltip before adding the chart.
I read some stuff out on the net that you have to create a div or add dojoTheme: true to your dojoConfig.  From what I did, neither of these are required.

I also read that I have to use a theme.  I am already including and using claro, so maybe that requirement was already met in my app.

Good luck.  I hope this helps someone.

Tuesday, October 11, 2011

Eclipse is Awesome

I'm sorry, but Eclipse is just plain awesome.  I wanted to do ssh right from Eclipse and after a quick google search, here I am editing code and running it in ssh in the same IDE.  So cool.  No plugin required.

Friday, October 7, 2011

Dojo Charting Woes

Man oh man.  I wish dojox.charting worked better.

I have a chart with 2 different types of plots, and several "Series" for both of them.  It's a stacked bar chart with a few marker lines also.  My page allows the user to regenerate the chart.  Unfortunately for me, the dojox.charting.widget.Legend does not update when I regenereate the chart, even if I call legend.refresh.  There is a solution on the net for this, but even the author admits, it is a bad workaround.

I found a solution.  Here's the code:

if (chart == undefined) {
chart = new dojox.charting.Chart("chart");
} else {

if (legend != undefined) {
legend = new dojox.charting.widget.Legend({
chart : chart,
horizontal : false
}, "legend");

Also I found that dojox.charting.widget.SelectableLegend does not work with my chart.  I think it is the multiple different types of plots that is messing it up.  If I un-check an item in the legend, the wrong bar/line is removed from my chart.  Whoops!

Thursday, October 6, 2011

Firebug won't delete a breakpoint

I kept running into this issue where Firebug 1.8.3 in FireFox 6.0.2 was not removing my breakpoints.  It removed the red dot, but continued to break at that line of javascript code anyway.  Even "Remove all breakpoints" did not help.  I found something that DID help.  You need to find and rename/remove your breakpoints.json file while Firefox is closed.  Mine is located here (Windows 7):


Tuesday, October 4, 2011

Rant #1

My iPhone 3G has gotten ridiculously slow. It's only 2+ years old.

Blogger for iPhone does not have horizontal keyboard.

Facebook on iPhone and iPad is slow and/or lacking features. On the iPad, you can't upload a photo.

Google docs is horrible on iPad.

You can't attach a google doc to an email in gmail?

What gives! Where is convergence?

Monday, October 3, 2011

Javascript JSON Query Languages

Here's a good link for Javascript JSON Query Languages.  The point here is to have a in memory data model of arrays, hashes, and objects and be able to perform SQL-like operations on them like select, join, union, order by, group by, etc.  Don't you wish your favorite javscript framework had this functionality already?

Friday, September 30, 2011


Thank you, thank you.  This is a very succinct description of how to do OOP with javascript.  It is exactly what I was looking for with really good examples and not much to read through.

Thursday, September 29, 2011

Dojo.stopEvent didn't work due to exception

function connectGenerateChartButton() {
	var buttonNode = dojo.byId("generateChartButton");
	dojo.connect(buttonNode, "onclick", function(evt) {
		console.log("Stop this event from doing a form submit.");
		console.log("Publish event for the generate chart button.");
		dojo.publish("generateChart", ["Woohoo!"]);

    dojo.subscribe("generateChart", function(text){
I am using pub/sub so I can be in a position to unit test my event code.  (I'm decoupling the UI event and the actual business logic.)  I ran into an issue with dojo.stopEvent as shown above.  Originally I had the stopEvent and publish lines switched so I would publish first and then stop the event.  Seems logical right?  I found out that my generateChart function had an exception that propagated out to my onclick handler and my stopEvent code was being skipped because of the exception.  I was getting a post anyway!

So for now I moved my stopEvent to be the first thing in this anon function.  That might be best practice anyway.

Also I need to learn more about exception handling.  I have a try/catch in my "main" function, but maybe that is not enough.

Wednesday, September 28, 2011

Closures in Javascript

So I never really understood closures or what they were for. This is a great reference explaining closures.


There is a link near the bottom that explains how to use closures for private members. Also closures can be used for callback methods.

Dojo charting bug

So I think I found a dojo bug today.  I have a chart that I am specifying the size with CSS.  It was working great.  Then I put the chart inside a TabContainer.  If the ContentPane is not selected, the chart will render with the default size of 400 x 300.  This is because the ContentPane with the chart is initially not visible.

I say I *think* I found a bug because I can understand why the size is defaulted.  Dojo would have to somehow render an invisible page to it could check the CSS and parent CSS to get the sizes, margins, offsets, etc. of all of the page elements of an invisible page, just to get the size of the chart correct.

Tuesday, September 27, 2011

Why use a Javascript Framework?

Why use a Javascript Framework?  There are several reasons.

  1. The framework will account for different browsers (IE, Firefox, Chrome, Safari).
  2. It may account for different devices (PC, tablet, smart phone).
  3. It will account for different browser versions.  For example, older browsers will not support HTML5.  A framework should have a fall back option.
  4. It helps with separation of concerns.  Any good framework will have a DOM query option so you can apply javascript functions to any DOM node.
  5. I'm sure there are other reasons, so I'll come back later and update this more.

Thursday, September 22, 2011

Javascript functions and OOP

This is really a must read about javascript functions and Object Oriented Programming.  I was just looking for the syntax of "call" and I got more than I bargained for, but that's good!  I agree with the writer, it's too easy to declare global functions (or functions on the outermost object - window in most cases).

Laptop Cup Holder

My laptop must think I'm thirsty.  The cup holder keeps popping out.  ;)

Wednesday, September 21, 2011

Chart Data Progress

OK, so I abandoned the DataSeries dojo object.  It was not very well documented and failing all the time.  So I did this, which I am pretty pumped about:

testData2 = [
{ name: "Development",
data: [1000,1000,1000,1000,1000,1000,1000,1000] },
{ name: "Test Site 1",
data: [1000,1100,1200,1300,1400,1500,1600,1700] },
{ name: "Product  #1",
data: [1000,1200,1500,4000,4000,4000,4000,4000] },
{ name: "Test Site 2",
data: [5000,3000,0,0,0,0,0,0] },

        // Other code omitted.

dojo.forEach( testData2, function(row,index){

dojo.store.Memory is not a dojo.data implementation

How many times can I shoot myself in the foot?  I was hoping that I could use the dojo.store.Memory object to store data in memory in my application and pass it to a dojox.charting.DataSeries.  That does not work.  You get an error something like, getFeatures is not a function.  And indeed it isn't.  Memory does not have a getFeatures function.  On further review, if you look at the documentation for KeyValueStore, you see that it says it is an implementation of dojox.data.  Seeing that Memory is in the "store" namespace makes you think it is a store, but it is not.

Dojo Charting with DataSeries

This is a good URL I found for working with dojo charts and using a DataSeries.


Tuesday, September 20, 2011

Dojo charting axis bug

That didn't take long.  I found a bug with dojo where the titleOrientation: "away" setting for an axis on a chart is not honored.

Luckily someone reported the bug already.

Javascript Book

Can anyone recommend a good book about javascript that has topics such as MVC, OOP, closures, overall best practices, unit testing, etc.  Put the book title in the comments.

Dojo chart failed to render

I've been doing a lot of dojo lately.  I ran into an issue recently where I was creating a chart programatically and using a div tag as my target node.  The chart was not working.  The issue was because I had assigned a class to my div tag and the CSS behind the class was causing the chart to not show up.  I think dojo really wants to assign its own styling.  Here's the div that caused the problem:

<!--This is bad to use with dojo charting.-->
<div id="badChart" class="div-area"></div>

The solution is to nest this div tag inside another one.  Apply styling to the outer div tag to your heart's content.


Hi.  Welcome to my blog.  This blog is for random thoughts about software development.  If I run into a problem and figure out a fix... I'll post it!  Hopefully it will help others solve similar problems.  I'll also post about software development patterns and some of my own ideas.

The name.  I named this blog, "Less is More" because of a lot of software development principles that point to reduction;  DRY: Don't repeat yourself;  Don't make duplicate code;  Separate your concerns, don't reinvent the wheel; etc.  It is my belief that less code is more maintainable... by definition.  If you have less code, you have less to maintain.  Code maintenance accounts for the lion's share of work in the life cycle of most software applications.  A good developer should use all methods at their disposal to write minimal, maintainable code.  I'll write more on this later.  Have a great day!