Dan Gowans My personal thoughts and mindless ramblings

TD Canada Trust, read this pseudo-code.

09.25.2010 · Posted in Thoughts

A weird thing happened this week.  My wife received a cheque in the mail from the bank itself.  It cited the account number of one of her investments, but gave no reason.  There was no letter in the envelope explaining the cheque, and the envelope was handwritten.  The cheque appeared legit, but when you don’t expect a cheque from your bank in the mail, it sparks some interest.

Sarah called our local branch that night.  They were equally confused, and requested her to bring it in.

After a meeting at the bank, and a couple follow up phone calls at home, we finally figured out what happened.  TD, you need to update your code.

When an investment rewards its interest, it has to go somewhere.  For some reason, the target account was not set for the investment.  I guess this investment rewarded twice in the past already.  (We never noticed.)  The first time, the interest landed in our savings.  The second time, the interest landed in our chequing.  And this, the third time, it could not decide a target account, so defaulted to a cheque.

We were told that three attempts are made to identify a target account, with a cheque as the last resort.  Hearing this makes my programmer head hurt.  A lot.  This is a bank.  They deal with our money.  Cudos for a default cheque case, but when nothing changes in your account structure, why would the target account ever be completely random?

I can only assume their target account identification code looks something like this.

String getTargetAccount (String investmentAcctNum) {
     AccountHolder person = getAccountHolder(investmentAcctNum);
     int choice = rollDice();
     switch (choice) {
     case 1, 2:
          return person.getCheckingAccounts()[rollDice()];
     case 3, 4:
          return person.getSavingsAccounts()[rollDice()];
     case 5, 6:
          return null;

For you non-coders out there, they basically roll a dice, and pick an account based on the result. If they don’t get an account result after three rolls, they send a cheque.

What the code should look like:

String getTargetAccount (investmentAcctNum) {
     AccountHolder person = getAccountHolder(investmentAcctNum);
     Account[] savingsAccounts = person.getSavingsAccounts();
     if (savingsAccounts[0] != null) return savingsAccounts[0];
     Account[] chequingAccounts = person.getChequingAccounts();
     if (chequingAccounts[0] != null) return chequingAccounts[0];
     return null;

What makes this code great is that is should work the first time, due to its non-random nature.

TD, please update your code. Restore some of the confidence I had in you.

One Response to “TD Canada Trust, read this pseudo-code.”

  1. Erin from TD says:

    Hi Dan,

    This is great feedback and I will pass it along to the appropriate team here. I’d like to have someone follow up with you on this. If you’re interested, please email customer.service@td.com with the subject line “Blog Posting”, and we’ll have someone reach out.

    Erin from TD

Leave a Reply