EC Tech Meetup May 20, 2014 – Was TDD a QA Coup d’etat?

Tonight is the next installment of  *hands on* for our local group.  With brewskies and Crown Royal.

There will be testing exercises and some TDD kata, and discussing the efficacy of TDD in coding with today’s modern methodologies.

A lot of you have noted there has been a (predictable) backlash against TDD.    My earliest memories of the methodology were of zealot/half coders from QA spitting bologna sandwich bits on our shiny developer faces while they told us we were all wrong about how we thought about software.   I personally worked on sites where directors argued that QA=Developer in a sprint.   Now when I look back I see that part of the evolution as a coup; that QA was trying to take over the development process by trying to argue that the creation process was nothing more than translating requirements and tests to code.  It sounded great in a manifesto . . . . but didn’t work in practice like so many other manifestos.  Eventually, and to this day, non-coding management uses  TDD as an bludgeon for their inquisition — the usual spiral to not so much build software as to set up a CYA network and pre-empt blame.  Good old pre-emptive blame, another Agile methodology.

Then, as now, we have argued TDD is merely a technique for the tool box.  Yes test, but I wasn’t ready to drill a hole into my engine block to test block temps just yet.  And software is not a set of tests, its a set of something that does something – for people.

That aside, the tasks on-hand will be this kata I gleaned from Roy Osherove’s site with many, many thank yous.

String Calculator

The following is a TDD Kata- an exercise in coding, refactoring and test-first, that you should apply daily for at least 15 minutes (I do 30).

Before you start:

  • Try not to read ahead.
  • Do one task at a time. The trick is to learn to work incrementally.
  • Make sure you only test for correct inputs. there is no need to test for invalid inputs for this kata

String Calculator

  1. Create a simple String calculator with a method int Add(string numbers)
    1. The method can take 0, 1 or 2 numbers, and will return their sum (for an empty string it will return 0) for example “” or “1” or “1,2”
    2. Start with the simplest test case of an empty string and move to 1 and two numbers
    3. Remember to solve things as simply as possible so that you force yourself to write tests you did not think about
    4. Remember to refactor after each passing test
  2. Allow the Add method to handle an unknown amount of numbers
  3. Allow the Add method to handle new lines between numbers (instead of commas).
    1. the following input is ok:  “1\n2,3”  (will equal 6)
    2. the following input is NOT ok:  “1,\n” (not need to prove it – just clarifying)
  4. Support different delimiters
    1. to change a delimiter, the beginning of the string will contain a separate line that looks like this:   “//[delimiter]\n[numbers…]” for example “//;\n1;2” should return three where the default delimiter is ‘;’ .
    2. the first line is optional. all existing scenarios should still be supported
  5. Calling Add with a negative number will throw an exception “negatives not allowed” – and the negative that was passed.if there are multiple negatives, show all of them in the exception message

    stop here if you are a beginner. Continue if you can finish the steps so far in less than 30 minutes.


  6. Numbers bigger than 1000 should be ignored, so adding 2 + 1001  = 2
  7. Delimiters can be of any length with the following format:  “//[delimiter]\n” for example: “//[***]\n1***2***3” should return 6
  8. Allow multiple delimiters like this:  “//[delim1][delim2]\n” for example “//[*][%]\n1*2%3” should return 6.
  9. make sure you can also handle multiple delimiters with length longer than one char

1286608618

The title is the remainder for evaluating the numerical sequence 9876543210 as an Integer in Java.  This number lies outsides the bounds of Integer.MAX_VALUE for Java; it’s an overflow error.

1286608618 is the overflow remainder for casting 9876543210 as an Integer in Java.

I ran across this error in some code I was working on that had credit card type account numbers; which are generally 16 digit numbers.  The program in question got the *same* account number from one table as a string, another database as an Integer, and a third table as a BigDecimal.  In the code there were also methods that did conversions  of this number to long and to int.  Normally values like this are stored as strings but I have no comment about the design of this software and database where such things could occur . . .

When the value 1286608618 came back as a value during a unit test, I thought it odd and instead of just taking it as incorrect I researched it.  Since a lot of people use 9876543210 as a test value, perhaps a lot of people have seen this.

There are a few interesting things about this error:

  1. Java doesn’t complain when the bad number gets assigned to Integer.
  2. Java just mindlessly returns the overflow value with no error.
  3. Java makes a few trips through its Integer range until it gets a number that fits within the range.  In the case of 9876543210, it is over 2 times the value of the range, to Java makes those trips through to get to 1286608618.

I wrote a little Groovy code to play around with this:

//Here's the integer and it's overflow
Integer i = 9876543210
println "overflow error for 9876543210: " + i

//Integer max value
BigInteger maxInt = 2**31 - 1
println "calculated max integer: \t" + maxInt
println "Integer.MAX_VALUE: \t\t" + Integer.MAX_VALUE

//Integer min value
BigInteger minInt = -2**31
println "calculated min integer: \t" + minInt
println "Integer.MIN_VALUE: \t\t" + Integer.MIN_VALUE

//get the Integer range
BigInteger range = maxInt  + 1 - minInt
println "range: \t\t\t" + range

//two trips around the raspberry bush calculation
BigInteger big = 9876543210
println "big: \t\t\t" + big
println "overflow remainder: \t\t" + (big - (2*range))

Here’s the outcome:

Well see here, I know thinking about this bakes my bean a little bit too.  There are number shifts and all kinds of thing going on. If you have underflow the same kind of logic applies as well.

I don’t understand why it just doesn’t error — what use is that remainder number at all?  Have no idea.

Tractor Lights and Upgradability

See those smaller white lights on the sides of this motorcycle headlight?  Those are called fog lights.  Harley Davidson calls them passing lights.

This is the front of a 2003 Harley Ultra.  When I bought the thing I was under the presumption that there would be parts, forever, for any Harley model.  The scale of Harley parts is massive — for instance, if you order catalogs from Dennis Kirk in Minnesota or J&P Cycles in Anamosa IA you have to specify HARLEY or THE REST.  The catalogs are massive, and the H-D catalogs for parts are as big as or larger than the catalogs for all other brands *combined*.

A sad day came a few weeks ago when I took my bike in and got maintenance done, and the one of my fog lights was burned out.   Harley service came back and said “$70 to fix one.”  What, for a bulb?  This was more than the usual exclusivity fee.

Well it turns out almost none of the dealers carries bulbs for 11 year old bikes anymore and they were going to upgrade me to something modern, and I am guessing, out of context with the timeless form so few manufacturers have achieved: Harley for one, and Ducati for another (IMHO of course).

But . . . no freakin’ lamps, a common maintenance item, for this bike?  That’s nuts. I told them no, I’ll get my own — they were cool with it (and I suspect  sympathized).

I trotted over to the local Farm and Fleet and there I found Phillips 4411 bulbs with the slip-on connectors I needed for $8 a piece.  They came up on the cashier screen as “tractor lights.”  Made sense — in the old days a lot of Harley dealerships shared space with John Deere, Case, and International Harvester equipment.

Finding standard parts for anything is a concern.    Once I talked with a guy who had toured South America on a bicycle — he said a person would be nuts to use a 700c wheel (commonest road bike size) because all’s they have down there are 26″ wheel parts — tubes, spokes, tires.   On the flip I remember owning a few Chevy pickups and the Haynes manual covered 1967-1984 — almost 20 years of interchangeable parts save some Navajo body decals  or an 8-track player.  Imagine . . . .

There are tie-ins to this idea in software.  For instance, when picking out a technology for a new application — like maybe UX frameworks — don’t we look at the one with the most options, support, and probably longevity?

And recently I have been researching big data engines.  Been playing around with Apache Tez and Cassandra and thinking, hmmmm, I’m going to analyze log files with this should I get good at it — maybe tie it into my web site data miner I wrote in Groovy.  Dunno.

A big data engine  evaluatory article I came across had this observation in the comments discussion how RavenDB failed to scale for them:

Speaking of RavenDB 2.0, you guys did a lot of funky stuff on the Raven Client that forced us to rewrite major portions of our app – limiting the number of async calls made in a single session to 1 was the issue, IIRC. I ended up scrapping the project and had us roll back to RavenDB 1.0 until we migrated off of it since there were just too many things we had to change at once in order for our app to support RavenDB 2.0.

So imagine that you put all this time into something and hit the feature wall.

My observations about this are:

  • You can only pick a technology as well as you can that day.
  • Nothing will prepare you for the type of obsolescence you will run into in the future.
  • Making things work might be cheap.  Maybe $8, if you get lucky.  But in my experience they get expensive.

For instance, an organization I did some FileMaker Pro work on waited too long to upgrade their database.  All their forms, everything, done for. Was time to sunset that application . . . or limp along knowing that death was near.

On the other hand you might get lucky.  XP just got sunsetted — after what, 13 years?   That’s a long life for any OS.

Software isn’t really a Harley; its not even a cultural artifact its just some code that does something for now.  Harleys have been around because the designers hit the form and functionality sweet spot right on. Even if I can’t get those 4411’s I can still get something newer for my ’03.  Cobol did that, the C languages and Java.   Bleeding edge might return ROI — or it might end up like the Excelsior-Henderson Super X — flashy, awesome and just not around anymore.  Maybe a little of both is best.

A Trite Exchange About Agile This Fine May

I just  had a great discussion about Agile with one of my technical buddies.  It seams this is popping up everywhere: Agile has become a management club.  And by club I mean both an organization and a tool with which to bludgeon.  These are some of the ideas that came out of our rather trite exchange.

The content you are trying to access is only available to members. Sorry.

Opera With Chrome Plugins

Firefox.  Dang it.

Coding some javascript and waiting for a build, I was checking out my OK Cupid profile and wiped my Chick-Fil-A grease on my LA Clippers t-shirt when someone walked up and said –

“OMG!!!  You are using Firefox!  What a moral outrage!”

Crap.  Can’t win here.  Time for a new third browser.   I have to use IE (reality) and Chrome.  IE, sigh.  Good ideas, bad implementation like a Corvair.  Oops that’s non-PC too.  Wait were Corvairs bad cars? Can’t remember.

Believe it or not I work in the stone ages and can’t install Safari on my Win 7 machine.   You need admin rights for that.  I know, crazy – a developer without admin rights????; my setup starts with what the front desk has which is so nuts.  But . . . I CAN install Opera.  And Opera is kinda neat because it’s a *version* of Google Chrome and is also my mobile browser of choice.

For a long time I didn’t do this because I couldn’t install any good plugins but this has changed – Opera 20 has a plugin that let’s you install Chrome plugins.

The two I absolutely need (besides developer’s stuff):

  • Xmarks — very implement for sharing project links between browsers, especially during testing.  And the profiles are awesome.  I organinze my research in folders this way too.
  • Controlled Multi-tab Browsing — this lets me limit my browsers to 9 tabs.  I am an infernal tab opener, and I read at Lifehacker.com that all’s you need are 9 tabs max — and I’m following that right now.  And seriously it’s a big help.

Be careful about the multitab limit plugins.  There’s another Chrome one I cannot recommend called Tabalot that does this (explicitly from their plugin site):

After reaching a configurable open tab limit (that excludes pinned tabs) Tabalot will automatically close the left-hand non-active tab.

 

There’s no prompt or anything as of this date – just closes the darn tab.  Sounded great until it closed a Google Doc I keep open all day and I lost my information for the day.

So anyway in Opera you can install Chrome plugins.  It’s a big deal to *me* because XMarks doesn’t have a deployment for Opera. To do this you need to first install a plugin called Chrome Extension.  Here are the steps:

  • Install Opera’s Chrome Extension.
  • Install your favorite Chrome Plugins – Opera will be treated like Chrome because they are based on the same WebKit core – as is Safari.
  • Xmarks will work properly in Opera (or it has for me in version 20).  Joy of Joys.

Now when these politics and religion talking people come sauntering around they’ll just see me with Opera, Chrome and IE.

But did I uninstall Firefox?  Heck no.  Never know when it might be PC again and Chrome be the next offender. I’m even keeping Sea Monkey on my PortableApps just in case someone sees me shopping at Walmart or the Co-op and complains about my browser.

I guess there’s always wget.

RIP Agile

Agile is Dead?

About 15 years ago I was in a conversation to two women and one brought up her new “cool” shoes. The lady with the shoes said “Do you like these? I got them at Target and they are sooo cool.” We looked down at them — basic Nurse Ratchet shoes with a trendy buckle to make them look motorcycle-bikerish, but basically pigs with lipstick.  The other lady said: “No, they just look like Target shoes.”

The content you are trying to access is only available to members. Sorry.

Xmarks Server 503 Error

Like many, I use Xmarks plugins to manage my bookmarks across multiple web browsers.

Recently the Xmarks install on Chrome was breaking.   I sync anything and got a 503 error.

After spending some time looking into it and finding no answer on the Xmarks site or anywhere else, I decided to reinstall the plugin, which resulted in a successful fix.

Here are the steps:

  • Backup your Chrome bookmarks:  ctrl-shift-O (or use the tool menu) to open the Bookmark Manager –Then Organize–>Export Bookmarks to HTML file. If you don’t backup you could make a mistake during the Xmarks sync and lose everything.
  • Uninstall the Chrome Xmarks Extensions from Chromes Customize Menu–>Settings–>Extensions.
  • Reinstall the Xmarks Extension.
  • Sync up XMarks.  If you use profiles, you can cancel out of the initial sync wizard, and then go into the Options in Chrome and assign the profile.
  • During the sync wizard I chose this setting which kept it from destroying my bookmarks on my other browsers and in Chrome:

Tech Thoughts April 22, 2014

  • Tonight is the first of the hands-on developer meetings – Ale and Algorithms – for our EC Tech Meetup at the Milwaukee Burger joint in Eau Claire.  7 pm.  Tonight I’m hoping to work on some problems including
    • Fizz Buzz
    • Armstrong Numbers
    • Prime Number detector
    • Reverse a String without API use
  • Since the meeting is only an hour or so long we may not get through all these.  I’ll be using  Groovy  . . . and beer and cheese curds.
  • This is the first of hands-on meetings to do TDD, build build servers, open source VM, and solutions for private business.
  • How exactly can you do TDD whne you are using Acceptance Tests as a target?  So . . .in (say) a two week iteration you start off with broken tests and then fix them?  The build server then reports red for two weeks. Yikes.  And imagine a release of several iterations over a few months . . . maybe thats an insane target and TDD doesn’t work on that level.
  • After you release an iteration MAKE SURE the business experts review the AT criteria and outcomes.  All that may have changed by the end of development.
  • In DB Unit — if you are loading your data from an XML file make SURE the first record of the same table has ALL the fields even if it doesn’t use them!  Else you’ll get a “Broked” error — can’t load missing fields.  For instance:

This breaks:

   <Object  Date=”[some_date]” ID=”77″  />

   <Object  Date=”[some_date]” ID=”77″  ObjectNumber=”3751″/>

This doesn’t:

   <Object  Date=”[some_date]” ID=”77″  ObjectNumber=”3751″/>

   <Object  Date=”[some_date]” ID=”77″  />

  • Java’s Big Decimal: Again, to iterate: instantiating with a STRING is better than a DECIMAL — but you just have to live with the non-compile time check. Sigh.  But don’t want those nasty decimals hanging off.  Here’s a pic of a Groovy test (compiles to Java):

Pretty important in financial calculations.  More on this later sometime.

The Downton Developers

In 2012 in St. Paul, Minnesota the Team One Club was founded for the exclusive developer of discerning taste. Membership includes nights out with Rocky Patel, Padrón, Doña Erô and Cohiba cigars and the finest of craft beer, scotch and rye whiskeys and of exceptional dining events.The content you are trying to access is only available to members. Sorry.

New Battery on a Palm M500

Check this device out: my old Palm M500. I dug it out of the boxes to see how it would work as a night bed reader, because it uses very little juice, you don’t need an overhead light (it’s backlit) and can do a reverse-color thing to keep the light wash down.  Also, no internet so no temptation to suck my life away reading more Page 6.

Sure enough, the battery was dead.

Do you want one for Christmas?

On Amazon and EBay you can get a new battery kit for about $9 delivered.  Excellent.  So I ordered one up.  You can also buy these Palms still for about $50 delivered.  Some people I had read are using them for LCD interfaces for things like drone flying or Arduino projects.  Maybe I’ll try that later on.

It also uses the Graffiti writing system, a short hand notation for writing in letters. Some of the newer generation probably never heard of it since Xerox held the patent for it and sued to have Palm stop using it and one.   Xerox also produced the first marketable mouse computer in the early 1970’s and couldn’t market it like Apple later on in the 1980’s.  I am guessing a lot of the newer generation never heard of Xerox either.

Here’s the kit, new batter on the left, and my opened Palm.  I also have an aluminum case accessory you can see at the top. The kit graciously came with a new battery and little torx screwdrivers.

The Palm M500 cracked open.

The fix is relatively simple.

  1. Take the back off.
  2. Carefully unhook the wire connector (note the color of the wires, but the connector has an orientation so it should be a no brainer).
  3. Remove old battery.  You have to be careful removing the old battery because it has adhesive on the back to hold it in place.  You can heat it a bit or go slow — then it’s out.
  4. Put the new battery in, replace the cover and you are done.

Check out the old battery that went bad (left) compared to the new battery (right) below.

The bad battery’s foil protective cover is puffed up.   Lasted about 13 years, no bad.  Cell phone batteries have this cover too, a great safety for your device against corrosion.  Whoever thought of this cover was a usability genius.

Old battery (left) and new battery.

New battery installed.

Voilà.

I’m not quite finding the device an answer to my reading needs in bed, but it’s easy enough to load books with the SD slot.  It’s just the resolution is too low.  I do prefer it over my phone though.

I also pulled out my GPS unit that attaches onto the Palm.  They thought of these kinds of accessories light years before Apple.  This particular model works well — I used to use it mon my motorcycle in a tank bag and had music on it as well.  Remember, at that time you didn’t have the all-in one phones.  Stand alone GPSs still dominate as the usable way to go anyway (I have a Garmin wrist GPS and a Lowe GPS — both much better than a phone).

But I’m still going to have some fun with this Palm because I can program it.  I will also pick up a GPS “shield” for my Arduino — maybe I’ll get on of those new mini-boards since I know some guys who do HAM/drones — and play around with that.

We’ll see.   Lady Gaga is in the headlines again . . . .

Palm GPS unit on the color version (505) of the M500.