Anti-Test Driven Development Arguments and Myths

Ok, I have run into the anti-TDD arguments on and off over the years.  Generally it comes from two primary sources.  The person who doesn’t want to do TDD no matter what, nor test, nor learn anything about the latest and greatest tech, they simply want left in their corner of the universe to code whatever they are coding until they drop dead.  Then there is the other individual who is a decent developer, but just has honest hesitations about the style.

The developer who has honest hesitations I can understand, can talk to, and can usually at least get a “Well, that sounds reasonable, but I’m still not sure” response.  Which is much better than the alternative of disregarding TDD outright.  The hope, is that this individual can at least try out TDD and see if it would work for them.

Even with the more open minded developer it is still difficult to put TDD into practice.  Why?  That’s simple, TDD is hard and forces a developer to step back into the basics and really think the problem through first.  Most developers (at least currently, maybe it’ll change) have a very “just attack the problem with code” type of response.  Often the way to break down problems is taught in computer science 101 level classes, but after that is often lost in all the cramming for math, algorithms, and other such material.  But the core fundamental idea of thinking the problem through clearly still needs to be broached.  TDD puts that idea forefront in the process by making a developer write the test to verify the problem statement first.

With all this stated, there are a few myths that I’d like to bust.  These myths are often what cause the first person to cringe away cowardly in their corner of the universe, and causes these hesitations in the second more open minded developer.  After busting these myths I’d hope more of the open minded developers can use the power and thinking that TDD encourages.  As for the first corner cringing coder, they’re a dying breed and I wouldn’t bet on their recovery.

The Myths

  • MYTH: But I can’t test every single thing that is written, so TDD just isn’t for me. The reality is, you can’t test every single thing and you shouldn’t.  You should stick to the logic, business process, and other parts of the code.  Don’t worry about the configuration, individual database nodes, or other arbitrary or configuration based bits.  The idea is to make you think through the problem spaces and architecture needed to work through those problem spaces.  So TDD is still something you should try, but don’t try to test every single line of code.  Focus first just getting through the logical, flowing, business related bits of the code you are writing with tests first.  This will get you appropriately experienced with TDD.
  • MYTH: You can’t test against boundaries, that becomes an integration test, so why even mock/stub/fake if I’m not testing the real framework/parts/features? Again, why worry about testing parts that you know or are not responsible for?  Don’t test the integration parts.  There is a reason QA exists, and defining and testing boundaries is what QA does great.  But you still need to test and confirm that your code works against those.  Mocking or stubbing against that gives you the confidence that your code logic will work against these integration points and also provides you a basis in which to work off of.  If you write the tests first, you also know you’ve thought through these integration points to a fairly thorough level.

Do you have anymore myths that should be burst?  Please feel free to toss a myth or two to burst in the comments, I’d love to hear others input on the matter.

Kata Kickin’ Some Prime Numbers

Lately I have been interviewing people for prospective positions in the company I work for.  In the various questions that I and others pose during these interviews one popped up as a prospective Kata.  The challenge is really quit simple, “Write a method that would take a int and check if it is a prime number.”  The following snippet is what I came up with.

protected bool IsPrime(int theNumber)
{
    bool isPrime = true;

    int theHalf = theNumber / 2;

    for (int i = 2; i < theHalf; i++)
    {
        var remainder = theNumber % i;
        if (remainder == 0)
        {
            isPrime = false;
            break;
        }
    }

    return isPrime;
}

The next idea that popped up was to find X prime number in order.  As the answer a question like, “What is the 6th prime number?”  I came up with the following method for that.

protected int GetPrimeByPosition(int position)
{
    int counter = 1;
    int thePosition = 0;
    while (true)
    {
        if(IsPrime(counter))
        {
            if(thePosition == position)
                return counter;
            thePosition++;
        }

        counter++;
    }
}

In the end the Kata is a simple 2 step problem.

  1. Write a method that determines if an int is a prime number.  i.e. “Is 5 a prime number?”
  2. Write a method that determines the prime number based on X order.  i.e. “What is the 3rd prime number?”

So based on these two steps, what would be some other steps to add to this Kata?  What are some other good interview questions that are short and simple for prospective employees to code through?

Respectable Behavior

I’ve always pondered good interactions from other developers.  What makes it easy, or not so easy, to work with another developer?  Here’s a few of my thoughts on these engineering types.

The Uber Ego Engineer.  Just be curious and interested in the work if you are or aren’t really well versed in something.  The last thing any engineer likes is the know it all engineer.  Fortunately I’ve not run into too many of these in my career.

The Energy Engineer.  I like to work with other engineers, and other people in general, that have an energy and look forward to their day.  Sometimes however an engineer can overdo the energy.  The excessive bouncing about, ADHD style approaches to software engineering can be very stressful on those around you.  So to those energy based coders, just settle into a Prozac just for a bit.  Thanks!

The the Doldrums Engineer.  This engineer that just can’t find a single thing right in the world.  It’s always sunnier somewhere else, the code isn’t right, the build builds but shouldn’t type is one of the most frustrating engineers to work with.  I can do it, and usually can find a way or two to snap them out of the doldrums, but it takes a huge effort.

That’s it from me for the moment.  What engineers do you know of that are good cohorts (or bad)?

First Post! Code Kata Alpha Counter

This is my first video screencast.  Please bear with me a bit while I blunder through this and a few more.  At some point I’m sure I’ll have down a professional glean!  😉

For this Kata Screencast I went with an extremely simple problem statement, which is generally a single step Kata that has multiple phases to it.  In the video I step through each of those steps one-by-one.  I think I did ok, except I realize after creating the video I do need to actually stop and talk my way through the problem.  I have the tendency to just start resolving the problem and only mention certain parts of my thought process.  I’ll work on that in my second video.

If anyone has any suggestions for another Kata or for the code int his Kata, please let me know.  Thanks!

Your Cloud, My Cloud, Security in the Cloud

I had a great conversation the other night while at the Seattle Web Analytics Wednesday (#waw) with Carlos (@inflatemouse) and a dozen others.  @inflatemouse brought up the idea that an analytics provider using the cloud, increases or at least possibly increases the risk of security breach to the data.  This is, after all a valid point, but because of the inherent way web analytics works this is and is not a concern.

Web Analytics is Inherently Insecure

Web analytics data is collected with a Javascript Tag.  Omniture, Webtrends, Google, Yahoo, and all of the analytics providers use Javascript.  Javascript is a scripting language, which is not compiled, and stored in plain text in the page or an include, or passed into the URI when needed.  This plain text Javascript is all over the place, and able to be read merely by looking at it.  So the absolute first point of data collection, the Javascript tags, is 100% insecure.

The majority of data is not private.  So this insecurity isn’t a huge risk or at least should not be.  If it is, you have larger issues before you even contemplate using an on-premise and cloud solution to bump up your compute and storage capabilities.  Collecting data that needs to be secure via web analytics is an absolute no.  Do NOT collect secure, private, or other important pieces of data this way.  If you have even the slightest legal breach in this context, your entire analytics provision could have this data scraped, possibly used in court in a class action suite, or in other ways even.

For the rest of this write up, I will assume that you?ve appropriately encrypted, or enabled SSL, or otherwise secured your analytics or data collection in some way.

Getting that Boost on Black Friday

eE-commerce has gotten HUGE over the last decade.  The last Black Friday sales and holiday season saw the largest e-commerce activity in history.  Omniture, Webtrends, and all of the other web analytics providers often see a ten fold increase in web traffic over this period of time.  Sometimes, for some clients, this traffic is handled flawlessly by racks and racks of computers sitting in multiple collocation facilities around the world.  However, for some clients that have exceedingly large traffic boosts, data is lost.  (yes, ALL the providers lose data, more so during these massive boosts)  The reason is simple, the machines can?t process in time or handle the incoming traffic because the extra throughput isn?t available to scale.

Enter the cloud.  The cloud has vastly more scalability, almost an infinite supply by comparison, to any of the infrastructure available to the analytics providers.  Matter of fact the cloud has more scale available than all of the analytics providers.  This is actually saying a lot, because Webtrends (and maybe some of the others) I know does an amazing job with their scalability and data collection, arguably more accurate and consistent than any of the other providers (especially since many of them just sample and “guess” at the data).

So when you extend your capabilities to the cloud for web analytics do you really increase your security vulnerability?  Most of the providers of web analytics have their own array of security measures, that I won’t go into on levels of security.  However, does introducing the cloud change anything?  Does it alter the architecture so significantly as to introduce legitimate security concerns?

Immediately, from a functional point of view, assuming good architecture, intelligent system design, and good security practices are in use already, introducing the cloud should and is transparent to clients.  For the provider it should not increase legal concerns, functional concerns, or otherwise pending the aforementioned items are taken care of appropriately.  But that is just it, every single current provider has legacy architecture, various other elements that do not provide a solid basis for a migration to the cloud for that extra bump of power and storage.

So what should be done?  What if a provider wants that extra power?  Can the technical debts be paid to use the awesome promises of the cloud?  Is the security really secure enough?

Probably not.  Probably so.  But . . .

This provides a prospective opportunity for a new solution for web analytics to be provided.  It provides a great opportunity for a modern cloud based solution, that provides more than just a mere Javascript tag and insecure unencrypted data to be collected for analysis.  It provides the grand opportunity to design an architecture that could truly lead the industry into the future.  Will Webtrends, Omniture, Unica, or someone else step in to lead the analytics industry into the future?

At this point I’m not really sure, but it definitely is an interesting thought and a conversation that I have had a lot of people at #altnet meetings, cloud meetups, and with cloud architects, engineers, and others that have similar curiosities.  I await impatiently to see someone or some business take the lead!