Pat Drummond :: life & technology

www.patdrummond.org

February 26, 2018

Software Design, then and now

I was reading 10 bad habits to break if you want to become a great developer from a newsletter and couldn't help thinking I could have written it in the 1970s. I am always surprised how much has not changed. The only subject I couldn't have written about was security (#10), because we didn't have internet connections to worry about. (We had other security issues.)

I had to learn most program design concepts from self-study, as program design methods were not being taught in most schools. I learned important lessons from an article in a magazine by Niklaus Wirth.  A light bulb went on when I read about  "designing software by stepwise refinement", later known as top-down design. (#3) I saw no evidence of design methods in any programs written by our engineers, not even the 'software engineer'.  I called it spaghetti code, as it was written in a linear way - module-free.

I was able to test out this top-down design in a fairly complicated project. Although it wasn't large in modern terms, it involved real-time user control and hardware systems that needed to communicate with each other. Although I could use a real-time operating system, I still had to write a lot of code in assembly language. Hey, don't laugh, - you work with the tools available. The design concepts are the same. And they worked!  (#7) 

Each of the "stepwise refinements" of the large problem were described in plain english.  I completed this before writing a single line of code. Really! When I finally began coding, the work was easy - just follow the design descriptions and test each module as you go. Maybe this design method only works in a small or medium project. (I never worked in a large team.)

From the same design concepts, I started coding subroutines with one entry and one exit, so each could be tested with all possible inputs before being used. (#2) It turned out that I was the only programmer who worked this way. The other people writing software coded in a linear fashion without structure or plan - or documentation. For some reason, programmers didn't see the obvious problem of working as if every program was simple, and could be coded in a short time using habits developed in their first computer class.

At the same time, I started documenting software modules, no matter how small, with my name, date, entry and exit parameters, and a functional description in plain english. (#3) The proof of the pudding was that another programmer had no trouble making changes to this system. (When I was tasked with making changes to someone else's undocumented spaghetti code, it was a real headache!)

By designing before coding, and testing each module early, final software testing went quickly, because most of the bugs had been removed early. In fact, people were amazed that the system went into use with no bugs - unusual at the time. The only complaint I remember was an error message on the screen that said "Try again stupid". Hey I was young.

January 06, 2018

Ice Storm 1998

Ottawa Sun photo
During the Ice Storm of 1998, I kept a small diary each day of what was happening in our home near Manotick, Ontario. Someday, I hope to read it and laugh...
{Original at web.ncf.ca/pat/pat/icestorm.html}

Jan. 5, 1998: We lost our power with the first ice storm that dropped 13 mm of record setting rain, freezing rain, then ice pellets (same as hail). By dawn, more than 24 mm of freezing rain had fallen, coating everything with 2-3 cm of ice. Although, we regularly get freezing rain in the winter, we hadn't seen anything like this since Christmas 1986. The forecast said more was on the way. To start at the beginning...

Jan. 6: Another 10 mm of freezing drizzle to add to the 24 mm already down, with yet another storm from coming. David & Joan Davies had made plans to visit us. We met them in 1989 when we cruised south in our sailboat and had kept in touch. They had been working in Hungary since David's retirement. They drove up from Kingston to visit us as planned, not having heard the weather warnings about the ice storm! Power is out for 100,000 homes in Ottawa-Carleton as hydro lines snap under the weight of ice, but no one outside the area seems to know anything about it. I suppose another storm doesn't make good news. They arrived on salted roads to see our trees hanging with the weight of thick ice coating everything. The power went again just after supper and lasted till the next day. We lit the fireplace again, and talked by candlelight and went to bed under many extra blankets. We thought it was over.

Jan. 7: The forecast is for another 28 mm of freezing rain! I don't see how the trees can take any more, never mind the roof. (Later it appears we actually got 38 mm!) Again we lost power just as we were finished cooking supper. Again, we lit the fire and candles as the drizzle continued. That night was constant explosions that was hard to sleep through. Each explosion was a large branch or tree coming down. It reminded me of movies of those whistling bombs in London during the war, with people waiting for them to hit.

Around 3 am I got up to check the basement and ended up repairing a leaky pipe from the sump pump with magic tape. Just to add to my humour, Skipper the cat threw up on the floor (no I didn't step in it). Then, one of our largest backyard shade trees came down, roots and all. There must have been 10 cm of ice on all the trees. The door frame over the patio door started to leak from an ice dam just as I was surveying the downed tree. Even in the dark, I could see that we were in real trouble and power would be a long time returning. All wires in the countryside are carried on poles. Only the straightest trees and spruces survived the ice load; everything else was coming down.
David & Joan escaped in their car with wide eyes the next morning just before the third ice storm began. They didn't stop till they got past Toronto (very smart to pass up visiting their daughter in Kingston as they were hit too).

The Skipper's 12 volt sump pump saved our basement with my car battery as charging unit! 20 hours of pumping from a 12 volt battery to pump water out of the basement is not bad as it needed pumping every hour. We were using the fireplace to heat the house.

Jan. 8: One of our neighbors closed up his house and left, and gave us his 2 kerosene heaters -- of course you needed to be aggressive to buy ANY kerosene, as it was like liquid gold! You could not buy a heater or fuel or a generator for any money. Ottawa-Carleton has declared a "state of emergency" today. Pray help comes before the inevitable deep freeze. January is not a very good time to lose power. We can't even find out which main line our power comes from! Estimate very between 2 hours and 2 weeks.

Jan. 9: More freezing rain in the forecast. Hydro workers are not making much progress as more lines go down as soon as they get one back up. We remembered that a good friend had a generator, but they were on holiday in Mexico. Things were looking serious by then, so we phoned his son, who broke into his parent's iced up toolshed to get the generator for us. He picked up some kerosene that we had located, and drove it all out to us in his 4-wheel.

Now we had enough power to run the sump pump and freezer too (warming up to -2°C by then). When it got colder, we had to unplug the pump, set a timer alarm so we could run an electric heater for a short time. I made a chart of how many amps everything in our house needed and we juggled the power to do only important things - like make coffee in the morning (we didn't really needed caffeine, but it made us feel normal to drink it). We were still cooking in the fireplace but eating mostly cold food.

Jan. 10: Today, the sun came out and we could see the eerie combination of thick ice shining in the sunshine combined with the terrible destruction it had caused. Every tree in the area showed damage. We had the only whole tree on the ground, but many others won't survive the damage. Cretien and Harris are touring the area as hundreds are now sleeping in emergency shelters. I had offered help to a neighbour to feed their cat. First time I did this, the cat swatted at me, drew blood, and my hand is now swollen.

I was coordinating a contest to design a new home page for the National Capital FreeNet. All the entrants and judges were working online. As soon as I had a few minutes where we didn't need to run the pumps or freezer, I got online and tried to catch up on this work using a small laptop. The Skipper had been home for a few days, thanks to a kind boss, so the exhaustion was shared.

Jan. 11: A friend dropped by with more kerosene on her way to visit her daughter, who has not had any power, water, or telephone - and had horses to feed and water! My problems seemed smaller. The Skipper went shopping at the hardware store for the growing list of things we need.

Jan. 12: 46°F (8°C) on the thermometer this morning. Brrrr. I phoned Mom to let her know we are OK, but I wonder if we are. I ended up going to Ottawa (the local clinic was closed) to discover my hand was infected from the scatch two days ago. Antibiotics and elevate the hand and REST (joke eh?). So now The Skipper had to do all the labour that required 2 hands. A neighbour was wiring everyone's generators up to their electrical distibution panel. Our house was third to get wired up and the furnace wouldn't work. Of course.

Jan. 13: After a $200 repair bill for a new relay on our "leased" furnace with a service contract, we had an electrician wire a heavy extension cord into the furnace -- for free. The generator ran the furnace for an hour and quit. Kerry arrived with the big 4 KW genny about 20 minutes later and asked "Are you Irish?!" At last, we are warm and dry without juggling cords. Ottawa's official emergency ended today. Workers from across Ontario are in the area and the military has been helping clear trees and dig wires out of the ice. There was a public meeting in Kars village, but The Skipper decided to sleep instead. Someone must have impressed the guy from Ontario Hydro that there were 300 houses here with underground wiring near the Kars line. That night, our subdivision was hooked up from Kars. It took me less than 2 minutes to get the breakers on and the furnace going! Warmth! In an hour I was having a hot shower! The Skipper observed that daily showers are highly overrated!

Power back! We got power back - after 9 days - just before it went down to -20°C! Many thousands are still freezing in the dark. Back in the land of light and heat. You never know how dependant you are on power until it's gone. They say we now have stolen the record of the largest peacetime deployment of troops in Canada from Winnipeg - folks out west are annoyed.
Someone said that it was all a "wakeup call". I responded that I had only learned one thing - I will never again live in a house with a sump hole in the basement floor! But for THAT, we could have winterized the house, emptied the freezer, packed Skipper cat and moved into the city (where some lost power for a few hours). The stress of trying to keep the basement from flooding, freezers from thawing, the house from freezing, and helping neighbours pump their basements, was exhausting work that never seemed to end.

The most amazing thing was that our newspaper arrived at our door even when the branches were raining down! I don't know how they did it! Our yard is a mess - we paid the neighbors son & friend with mighty chain-saws to clean it up and the front of our yard is now about 5' high with branches stacked up from one side to the other. We also have lots of firewood although I may not have another fire for a long, long time. There are many thousands still without power. We discovered that modern insurance policies don't cover any of the expenses we've had so far, except for the dent in the car from a falling limb.

Jan. 14: Driving into town for a much needed break and dinner, we saw just what a mess the wires and poles are in. There were workers in cherry-pickers working on every second road. On the way home we saw very few lights outside the towns and villages. No lights between Manotick and our group of homes and none beyond. Areas south-west of us toward Winchester are hardest hit in this area with estimates of a month for power. They didn't even have phones south of us.
Our friend, who owns the generator we borrowed, came back from Mexico with his wife, who had a broken wrist that still needed to be set! He immediately had to leave for Edmonton (-35°C!), saying to The Skipper, "We sure have a set of book-ends!"

My mom in Rosetown, Saskatchewan was complaining about the very cold temperatures in the middle of all this, and I said, "Yes, but your house is WARM!" It's all relative I guess. I hope you feel warmer just reading this!

Jan. 23: It isn't over yet. Forecasting more freezing rain...
    Virtually yours,
    Pat Drummond
What made the ice storm so unusual, was that the freezing rain went on for so long - 6 days quietly coating everything in a thick layer of beautiful deadly ice. 4.7 million Canadians without power in the middle of winter - most in Quebec and eastern Ontario (and New York State too). 100,000 people took refuge in shelters. There were at least 25 deaths, many from hypothermia.

Freezing rain brought down millions of trees, 120,000 km of power lines and telephone cables, 130 major transmission towers and about 30,000 wooden utility poles. 14,000 troops were deployed. There were 792,514 insurance claims with $1.6 billion paid by insurers, a record. [Environment Canada: 1998 Ice Storm].

Ten Years Later

Most stories about the 'storm' talk about keeping warm and hot food. Our #1 concern was flooding. Even with a 12-volt backup pump, we had a constant struggle during the first few days.

August 14, 2003: On a fine summer day, we lost power with no explanation. Our backup 12-volt pump failed even though we test it every month. After using a neighbor's generator, we finally bought our own. (In '98 even our borrowed generator failed after a short time.) We no longer go away without having someone nearby who can "lift", operate and connect a generator - the down-side of living in an area with unreliable power.

August 18, 2003: Power shortages caused the federal government in Ottawa to send 40,000 employees home for a week. The government appealed to everyone to turn down their A/C. We walked in the evening and heard no air conditioners at all running in our rural neighbourhood, yet friends in the city announced proudly they were running their A/C "only at night". People just didn't get it, even after the 1998 disaster.

December 1, 2006: This one-day power failure caused as much basement flooding as the Ice Storm because the ground was soaked from rain. People who were at work had no chance before their basement sump overflowed. Fortunately we were home to set up the generator - the sump pump was running every few minutes.

2008 10th anniversary: I was approached by the newspaper about using this diary, but I just couldn't read it. I still get a knot in my stomach whenever we have freezing rain or the power goes off, which happens more frequent and last longer.

2018 20th anniversary: Again I was contacted by a local newspaper and CTV Ottawa. I still cannot read this diary, but maybe the paper can use some of it.

What could have been done better...

  • Information broadcast on AM and FM radio simultaneously is extremely important to the public. During power outages, most people have a portable radio and a telephone but not much else. Everyone wants to know what's happening, when it will come back on, where to go to get water, supplies, gasoline, medicine, etc.
  • Our local medical clinic didn't even spend the time to put a message on their telephone answering system. No instructions where to go in an emergency for normal medical care. It simply shut down. God knows where the doctors went. I had an infected hand (feeding neighbour's nasty kitty) and had to be driven into the city (30 min.). Why didn't the city or army get the clinic operational and get the doctors back?
  • Many communities set up soup kitchens (well, ok they didn't call them that but you could get a hot meal). Trouble is many didn't know about them. I would have killed for a hot meal during those nine cold days. Now we keep a propane stove handy at home, but then we heated things on top of a kerosene heater. Even after we got a generator, we discovered the original power surges broke our microwave - and furnace control!
  • People in the city with power didn't understand the misery happening to their friends in the rural areas. We actually had "tourists" who would drop by without calling to see if we needed anything. We discovered only fellow sufferers actually helped us.
  • The army arrived to check on people - about 6 days too late. People who couldn't cope had abandoned their homes to the ice and water (coming in the bottom) days before. They should have just helped hydro workers. Besides, how is a 20-year-old going to help us, arriving empty-handed (nor did they ask if we needed anything). We had tons of food but no way to cook anything. We had tons of sump water to flush a toilet, but no water to drink.

November 27, 2017

Banking Frustrations

Trying to authorize regular payments to a bank account has me scratching my head. You'd think bank staff would know the products they sell - and you'd be wrong.

I was told by my financial institution that I needed to supply a "void" cheque so they could deposit funds to my savings account (at an unnamed bank).  The bank printed a check for the account - I explained I needed it to authorize regular payments from another financial institution.  You'd think the bank teller would know what is needed to authorizing payments from another financial institution - and you'd be wrong.

The next day I wrote "VOID" on the cheque and emailed a scanned image to the financial institution.

But now they say they can't accept a "counter" cheque.  Due to financial regulations, they require either void cheques  imprinted with my personal information OR a Pre-Authorized Payment Form that includes a bank teller's stamp. You'd think the bank teller would know I needed this form to be used by a financial institution - and you'd be wrong.

So back to the bank to get the proper form.  I scanned and emailed it to the financial institution. Again it was not good enough to use - no bank stamp!  I had not explicitly asked for it, but you'd think bank staff would know the form needs to be stamped - and you'd be wrong!

I still don't have the form required for automatic deposits to my account, but I'm getting there.

During all this, I was also trying to get information about the "high-interest savings account". On the first visit to the bank, I asked the teller's supervisor how often interest was calculated and deposited, and was told calculated monthly and deposited annually. You'd think the bank supervisor would know the right answer. But it sounded odd, so I checked the bank website. It said interest was calculated daily and deposited monthly. On my next visit to the bank, I told this to another teller and asked: "Which is correct - the supervisor or the website?"  After spending 10 minutes in the supervisor's office, she gave me a printout from the website.  I told her I'd already seen that and could she "please answer my question". She asked me to repeat the question!  Her answer: "The website is always right".  Right.  But still, you'd think at least one of four bank staff would know the products they sell - and you'd be wrong.

And more....
I had a similar experience trying to change my (Canadian) government payment to make automatic deposits to a different account. I thought it was a simple change in my online account - except they close accounts not used in 2 years! So I went through the lengthy process of applying again and got an error message with no explanation. I phoned the number given but only found out the error means my access code is obsolete, and was given a second number to call for further help. That got me nowhere, but was given a third number to call someone who could give me an "access number" to get my online account back.  By this time, the office was closed. The next day, I got someone on the phone who not only gave me a new access number but also changed the  bank account right on the phone. I'm saving that phone number.

September 27, 2017

Google Keep is all I need for quick notes and photos

I use a Windows PC and an Android phone. Obviously, the first thing I did was set up my calendar and email.  After that, Keep was an obvious choice for a note-taking tool because it's timple to use and synchronized to my Google account and available on any device using the Keep app or https://keep.google.com.   (To all you Evernote fans, I really just need a simple tool like Keep.) 

First, you choose how you want to create the note: type, type a list, draw, dictate, or take a photo.

1. Note
Tap or swipe your text, then tap the back arrow (or back key) to save the note. To differentiate notes, I like to colour them using the palette icon: important notes are yellow, lists green, phone numbers blue, unimportant notes gray. This helps if you have lots of notes! It's also easy to add a label - create your own labels of course.  I use: health, map, shop, todo, travel. Tap the hamburger icon ☰ and select todo to see all the notes (including archives) about things you forgot to do!  I actually type most "notes" on my PC but try the Swiftkey or Kii keyboard app on your phone to swipe rather than tap - gesture typing is faster once you get used to it.

2. List
Need a grocery list?  Easy. Type it at home on your PC and check off items on your phone as you buy them.

3. Draw
Want to 'write' your note instead of typing? Easy. Or draw a diagram - or erase parts of it.

4. Camera
Need to take a quick photo of something in a store? Easy. I take most photo notes on my phone with a price or comment. I might give it a tag "shop" or archive it if it's just for reference, rather than cluttering up my list of notes.

5. Voice
Last, but not least, you can dictate your note.  Very easy!  Well, it's easy on Android anyway, since you've probably already customized your voice dictation.

That's it. Make your life simpler with great tools.

May 31, 2017

Amazon has it figured out

I've been buying online for many years and I wish I had written a how-to book on e-commerce mistakes to avoid. That ship has sailed.  Amazon is a case study in how to do it right. Proof?  I find myself comparing sources and often find myself buying from amazon.ca (I live in Canada, which requires extra care online).  Here's a few reasons why Amazon gets my business so often. 

First, they have grown so much, they have a separate website for Canada, which means you don't have to convert prices. (Neer buy from stores that do not even mention which $ they use.)

2.  Amazon almost always has the item I am looking for - even items that have been disappeared from brick & mortar stores.  Best of all, they have lots of choice - even used items (I once bought a used book for $.01.) They list the item with the lowest price and shipping, with links to other items, which saves a lot of time. 

3.  They have the shipping problem figured out. One of my first online purchases was 4 stainless steel wine glasses. I contacted the only Canadian business that sold them using their web form, but they didn't even answer!  I  ordered from a U.S. website. By the time the box arrived at the door with unexpected customs fees, the delivery cost more than the glasses!  Fortunately things have improved since then. Amazon will indicate right at the top if they cannot ship to your address (if you are logged in). The shipping cost is often shown under the price, and sometimes the city it is shipped from.  Too many e-stores still make you create an account and proceed to payment before you can find out the shipping cost - what a waste of time. Last time I bothered to do that, the shipping for a very small item was $42 - Amazon charged $5 for the same thing.

4.  Customer reviews are invaluable - if you can filter out the obvious paid comments.  Just read the 1-star comments first. To go along with reviews, check the list of items customers "also viewed" or bought for useful accessories. Adding them now, rather than later, can pop your total over "free shipping" minimums - which are lower than most other e-stores. And many items offer free shipping. Small items usually arrive by postal mail.

👉I have one beef with amazon.ca - it's often impossible to know if the item will be shipped from Canada or another country. If the business does not want you to know where it is located, too bad. Although, if shipping is going to take 4 weeks, you can pretty well guess it's coming from China. Since there is no duty added to the cost, I assume it's a regulation loophole.

[I do not work for Amazon and am not being paid to write this. -Pat]