17 May 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.

9 May 2017

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 Hierarchy
  • Ctrl + T Quick Hierarchy
  • F4 Show Type Hierarchy

Switch View to...
  • Shift + Alt + Q then C Console
  • Shift + Alt + Q then Z History
  • Shift + Alt + Q then O Outline
  • Shift + Alt + Q then S Search
  • Shift + Alt + Q then Y Synchronize
  • Shift + Alt + Q then T Type Hierarchy
Java Comments

  • Ctrl + / Toggle Comments
  • Ctrl + 7 Toggle Comments
  • Shift + Ctrl + C Toggle Comments
  • Shift + Ctrl + / Add Block Comments
  • Shift + Ctrl + \ Remove Block Comments

Run / Debug

  • Run Java Application
  • Run JUnit Test
  • Debug Java Application
  • Debug JUnit Test
  • Step into method
  • Step over instruction
  • Step and return
  • Resume execution
  • Inspect

21 April 2017

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:

13 April 2017

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 minutes, I pulled us into a higher-level discussion, so that I could map the home-brewed implementation to concepts I had already used on several previous projects.

I would suggest that there are at least 5 common elements that any functional testing framework will require of the devs who write tests and expand the framework. Since my Preaching class (see my bio!) taught me to work in memory hooks, I'll spell the acronym "STAMP":

  1. S - Scripting: some way to define a sequence of actions
  2. T - Test Cases: the ability to define and differentiate any number of different test scenarios
  3. A - Asserting: an ability to compare an expected state or condition against the actual state or condition
  4. M - Mapping: an association between the screen elements and the test framework
  5. P - Persistence: a means of defining and injecting data with which the UI will interact, since UI state and functional behaviour will often depend on some notion of persistence

30 March 2017

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.

24 March 2017

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!

10 March 2017

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?

22 February 2017

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: http://www.se-radio.net/2017/02/se-radio-episode-282-donny-nadolny-on-debugging-distributed-systems/

15 February 2017

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.

8 February 2017

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.