Skip to main content


Showing posts from 2017

Debugging Stories: Problems Logging in

I came across an interesting Debugging Story about login credentials that only worked when the user was seated. Whenever they attempted to login while standing, their credentials failed. Until one wise debugger asked the right question. Read the story here, in this book excerpt from Programming Perls by Jon Louis Bentley.

It reminded me of one of my own stories: the new user whose initial password refused to work.

I was part of a small team making a web portal for a medical insurance company. It would let medical practitioners submit predetermination-of-benefits requests before the proposed procedure was performed. We created a first roll-out to three partner offices, with a minimal set of useful features. We called it our Beta release.

Two of the offices began using the system right away. The third could not log in.

Eclipse Keyboard Shortcuts - Neon (4.6)

I created this page as a personal quick-reference lookup. It will therefore not worry about completeness (try here if you want a more complete list). My personal list will also be in a least-to-most-common use sequence. After all, the ones I use all the time I already remember. It's for the more occasional ones that I want a quick reference.

Ctrl + Alt + H Open Call HierarchyCtrl + T Quick HierarchyF4 Show Type Hierarchy
Switch View to...
Shift + Alt + Q then C ConsoleShift + Alt + Q then Z HistoryShift + Alt + Q then O OutlineShift + Alt + Q then S SearchShift + Alt + Q then Y SynchronizeShift + Alt + Q then T Type Hierarchy Java Comments

Ctrl + / Toggle CommentsCtrl + 7 Toggle CommentsShift + Ctrl + C Toggle CommentsShift + Ctrl + / Add Block CommentsShift + Ctrl + \ Remove Block Comments
Essentials for Java Coding

Ctrl + 1 Quick Fix - opens a context menu with useful time-saving coding shortcutsShift + F10 Opens Context Menu just like a right-clickCtrl + Shift + O Organi…

Algorithm to Find All Divisors of BigInteger

I was working on one of the math programming challenges from Project Euler recently and needed to implement an algorithm to find all of the divisors of a BigInteger.

A bad brute-force approach would be to visit all values from 1 to N and see which ones divide evenly into N.

A better approach would be to just check all values from 1 to the square root of N. Any values found that divide evenly into N will also give another divisor, since if we have value i then we can find j = N / i where i <= j

But the Java API for BigInteger does not include a calculation of its square root. And I don't want to write an algorithm to calculate the square root today. This algorithm, however, is almost as efficient as one limited by the square root:

STAMP: The 5 Elements of Writing Automated UI Tests

What are the common elements for writing and running automated UI-driven functional tests?

I am a software developer, not a QA tester, so my interest is in writing some form of scripts to perform tests through a user interface; I am not into tools that record a user's UI interaction.

The question arose recently, while I sat through an introduction to the custom-built testing framework of a project I am working on. (first, a clarification: by "framework" for this article I mean the custom code that a development team needs to create in order for the automated testing system to interact in a meaningful way with the production code. I do not intend it to refer to the testing platform itself. I'll call a tool like jUnit or Selenium a tool or a platform, and the set of tests, test doubles, and other artefacts of testing a specific system I will call the Framework.)

My guide for the learning session had a tendency to do deep-dives into the low-level details. After several …

Essential Eclipse Plugins: Source Control

Source Control or Version Control management tools are a reality of modern development, playing an essential role in helping teams collaborate and helping projects track code-base changes over time.

As I have moved from one team or organization to another, I have met different Source Control tools.

Whichever one you work with, there is probably an Eclipse plugin for it. Many are good enough that for day-to-day dev work you will never need to use the command line, saving those interactions for the rarer, more administratively difficult tasks.

The essential thing is to have a plugin for those day-to-day dev activities, but which one depends on your team's tool. I will touch on some of the best ones here.

Essential Eclipse Plugins: Ant Visualization

Apache Ant is a pure-Java build tool that made quite a splash in its day, and did a great job superseding the Make tools.

Do people still use Ant? Many have moved to Maven or Gradle, but Ant has been around long enough that some projects have built quite complex structures of targets.

XML files that stretch into several hundreds of lines long, with calls and dependencies, can make understanding the Ant build script difficult enough, and maintaining it all the more challenging.

Any time I have had to modify a complex build file, I would start by sketching the targets and their relationships. This Eclipse plug-in does all that tracing and sketching for us, by creating a visual representation of the targets and their links. Much simpler and faster!

Changing Default Program for File Extension in Windows 10

I recently set up a new Windows 10 computer. This included installing some of my favorite freeware utilities.

Then I went into the W10 Settings tool to change the default program for certain file type extensions to use my preferred tool rather than the pre-installed default.

Alas, the only options were the pre-installed software, or "Look for an app in the store"

But I don't want to buy or download an app, I have my preferred one already installed. How can I select it?

An Excellent Debugging Story

I love a good story of the challenges faced in solving a deep, challenging bug. The adrenaline rush of solving problems, bug-hunts included, is a big part of what drew me back into software development after a few years doing other things.

The most recent episode of the Software Engineering Radio podcast tells the tale of one of the most engrossing debugging stories I have heard in a long time. Donny Nadolny of PagerDuty tells the story of how they hunted, isolated, duplicated, and solved a bug in the midst of a distributed system spanning multiple data centres in different regions. They had to drill deep into their stack, and were ultimately successful.

Check it out here:

Essential Eclipse Plugins: Eclipse Color Theme

This is fun little plugin, one of the most popular on the Eclipse Marketplace, gives you a quick and easy way to apply a consistent, customized color theme to many of the Eclipse editors.

Eclipse gives you lots of control over syntax coloring already, but there are gaps in its features, and the themes do not easily cross types of editors, like Java, XML, Ant, Scala, etc.

This tool lets you apply a theme quickly and easily across all supported editors. Match your color theme to your ambient lighting, your corporate colors, your favorite team. Whatever strikes your fancy.

Essential Eclipse Plugins - AnyEdit Tools

This is one of the most useful little extensions I have ever come across. It's a plugin that adds several new tools to the context menus in many different Eclipse text-based editors.

I first encountered the power and convenience of this tool on a project to clean up and refactor a crusty old code-base. Too many times in its past history, the developers had used the Copy-Paste-Tweak approach, which left lots of nearly-duplicated code that did 99% of the same thing. Using Eclipse's built-in refactoring tool to Extract Method would not always refactor them all.

Pushing Specific Commit in Eclipse Git

This post describes the real-world scenario, then offers the steps to solve the issue at the bottom. If you are in a hurry, jump to the end of the post to see the steps in Eclipse, without my self-indulgent story-telling!

A few months ago, my team switched from the ancient Visual SourceSafe to Git. While we tried to minimize the process impact, the change-over was such a big shift in thinking that, months later, I still field several questions a week.

Here is a recent trouble-shooting sample: a colleague got caught in mid-task with an urgent fix, and mucked up some commits in her local repository. Her question: how can only the fix-commit be pushed.

Email excerpt:
Hey Steve!
Okay - so I have 2 files that I need to push to repository X for a high priority fix for tomorrow.

I have a 3rd file that I was in the middle of changing when I had to interrupt to get the high priority one fixed and in.  It is currently in a state of flux and full of errors.
But when I went to do a pull so that I cou…

Faster Git History View in Eclipse

Actually, 2 tips about Git History view in Eclipse today:
(1) Faster loading of History view in Eclipse Sometimes in Eclipse, viewing the History of a file, folder, repository or branch can take several seconds to load. Git promises faster access to the History of source changes because they are local, and this is generally true. But when there are thousands of files and many years of history, including occasional refactoring and restructuring, the History view can lose some of that speed.
One simple setting change made our History views in Eclipse faster: In Eclipse, select Window -> Preferences. In the tree-view of categories, navigate to Team -> Git -> History Uncheck the preference for “Follow Renames” Click OK.
This made a big speed improvement in our History view’s load time.  But it comes with a cost:

Abort a Git Merge or Cherry-Pick

Recently a colleague of mine used the Git Cherry-pick feature to bring one of their commits from one branch of our repository to another. They hit a somewhat complex merge conflict and, in trying to resolve all of the conflicts in the file, they got confused about what needed to be done.

They came to see me with the question: can they cancel their cherry-pick and partial merge, and start over?

The answer is Yes: it is possible to abort a merge or a cherry-pick Git operation.

Most of the time it is not needed; with a little work and human intelligence, the merge conflicts can be resolved without too much trouble. But sometimes, in cases like my colleague faced, a more complex merge winds up confusing the developer, and they want to go back and start over.

If you use git from the command-line, it’s as simple as: git cherry-pick --abort or git reset --merge
On my team, about a quarter of us use Git from the command line, but most - like my colleague in this story - prefer to use the Eclipse…