Thursday, 29 December 2016

TDD and the Response


TDD is dead. Long live testing.


Test-first fundamentalism is like abstinence-only sex ed: An unrealistic, ineffective morality campaign for self-loathing and shaming.

It didn't start out like that. When I first discovered TDD, it was like a courteous invitation to a better world of writing software. A mind hack to get you going with the practice of testing where no testing had happened before. It opened my eyes to the tranquility of a well-tested code base, and the bliss of confidence it grants those making changes to software.

The test-first part was a wonderful set of training wheels that taught me how to think about testing at a deeper level, but also some I quickly left behind.

Over the years, the test-first rhetoric got louder and angrier, though. More mean-spirited. And at times I got sucked into that fundamentalist vortex, feeling bad about not following the true gospel. Then I'd try test-first for a few weeks, only to drop it again when it started hurting my designs.

It was yoyo cycle of pride, when I was able to adhere to the literal letter of the teachings, and a crash of despair, when I wasn't. It felt like falling off the wagon. Something to keep quiet about. Certainly not something to admit in public. In public, I at best just alluded to not doing test-first all the time, and at worst continued to support the practice as "the right way". I regret that now.

Maybe it was necessary to use test-first as the counterintuitive ram for breaking down the industry's sorry lack of automated, regression testing. Maybe it was a parable that just wasn't intended to be a literal description of the day-to-day workings of software writing. But whatever it started out as, it was soon since corrupted. Used as a hammer to beat down the nonbelievers, declare them unprofessional and unfit for writing software. A litmus test.

Enough. No more. My name is David, and I do not write software test-first. I refuse to apologize for that any more, much less hide it. I'm grateful for what TDD did to open my eyes to automated regression testing, but I've long since moved on from the design dogma.

I suggest you take a hard look at what that approach is doing to the integrity of your system design as well. If you're willing to honestly consider the possibility that it's not an unqualified good, it'll be like taking the red pill. You may not like what you see after that.

So where do we go from here?

Step one is admitting there's a problem. I think we've taken that now. Step two is to rebalance the testing spectrum from unit to system. The current fanatical TDD experience leads to a primary focus on the unit tests, because those are the tests capable of driving the code design (the original justification for test-first).

I don't think that's healthy. Test-first units leads to an overly complex web of intermediary objects and indirection in order to avoid doing anything that's "slow". Like hitting the database. Or file IO. Or going through the browser to test the whole system. It's given birth to some truly horrendous monstrosities of architecture. A dense jungle of service objects, command patterns, and worse.

I rarely unit test in the traditional sense of the word, where all dependencies are mocked out, and thousands of tests can close in seconds. It just hasn't been a useful way of dealing with the testing of Rails applications. I test active record models directly, letting them hit the database, and through the use of fixtures. Then layered on top is currently a set of controller tests, but I'd much rather replace those with even higher level system tests through Capybara or similar.

I think that's the direction we're heading. Less emphasis on unit tests, because we're no longer doing test-first as a design practice, and more emphasis on, yes, slow, system tests. (Which btw do not need to be so slow any more, thanks to advances in parallelization and cloud runner infrastructure).

Rails can help with this transition. Today we do nothing to encourage full system tests. There's no default answer in the stack. That's a mistake we're going to fix. But you don't have to wait until that's happening. Give Capybara a spin today, and you'll have a good idea of where we're heading tomorrow.

But first of all take a deep breath. We're herding some sacred cows to the slaughter right now. That's painful and bloody. TDD has been so successful that it's interwoven in a lot of programmer identities. TDD is not just what they do, it's who they are. We have some serious deprogramming ahead of us as a community to get out from under that, and it's going to take some time.

The worst thing we can do is just rush into another testing religion. I can just imagine the golden calf of "system tests only!" right now. Please don't go there.

Yes, test-first is dead to me. But rather than dance on its grave, I'd rather honor its contributions than linger on the travesties. It marked an important phase in our history, yet it's time to move on.

Long live testing.

Source: http://david.heinemeierhansson.com/2014/tdd-is-dead-long-live-testing.html


RIP TDD

DHH has consigned TDD to the scrapheap of history http://david.heinemeierhansson.com/2014/tdd-is-dead-long-live-testing.html. I'm sad, not because I rescued it from the scrapheap of history in the first place, but because now I need to hire new techniques to help me solve many of my problems during programming:

  • Over-engineering. I have a tendency to "throw in" functionality I "know" I'm "going to need". Making one red test green (along with the list of future tests) helps me implement just enough. I need to find a new way to stay focused.
  • API feedback. I need to find a new way to get quick feedback about my API decisions.
  • Logic errors. I need to find a new way to catch those pesky sense-of-test errors I'm so prone to making.
  • Documentation. I need to find a new way to communicate how I expect APIs to be used and to record what I was thinking during development.
  • Feeling overwhelmed. I'm really going to miss how, using TDD, even if I couldn't imagine an implementation I could almost always figure out how to write a test. I need to find a new way to take that next step up the mountain.
  • Separate interface from implementation thinking. I have a tendency to pollute API design decisions with implementation speculation. I need to find a new way to separate the two levels of thinking while still providing rapid feedback between them.
  • Agreement. I need to find a new way to be precise with a programming partner about what problem I'm solving.
  • Anxiety. Perhaps what I'll miss most is the way TDD gives me an instantaneous "Is Everything Okay?" button.

I'm sure I'll find other ways to solve all these problems. In time. The pain will fade. Farewell TDD, old friend.

Source: https://www.facebook.com/notes/kent-beck/rip-tdd/750840194948847/

Sunday, 18 December 2016

The condescending and pompous Lisa Crispin

WHY is it so hard for software professionals to see the obvious (I admit, it was hard for me too):
1. Quality and testing activities are the responsibility of the whole team, not of only the QA team
2. The programmers who write the production code can do the test automation in a tiny fraction of the time it would take the testers to automate in any tool, especially one like QTP
3. If the testers don't have to waste time trying to automate tests (probably creating tests that are too expensive to maintain and provide bad ROI), then they have oodles of time to collaborate w/ customers & devs to elicit examples of desired and undesired behavior, which they can then turn into test cases which are automated quickly and easily by the programmers. Then the same testers will also have oodles of time in which to do the essential exploratory testing. Everyone gets to do what they do best, everyone collaborates, high s/w quality results.

Sigh.

Source: http://swtester.blogspot.com.au/2011/07/quality-center-must-die.html


Monday, 22 February 2016

OS X - Messages

I couldn't work out why I was able to send a message to a mobile number.
How did iMessage determine where to send it?

It turns out that it could because when a mobile is logged in with an Apple ID, the mobile number becomes associated with the Apple ID.




iMessage is the service supported by Messages.

OS X

FaceTime







Messages








iOS

FaceTime







Messages








Thursday, 18 February 2016

OS X - show all filename extensions

I was in Finder and I couldn't work out why checking the preference "Show all filename extensions" wasn't working.

When you uncheck "Show all filename extensions", the extension will be displayed depending on the "Hide Extension" setting of each file.

When you check "Show all filename extensions", the extension will be shown, even if "Hide Extension" has been checked.

However, the extension of a particular file was not displayed, even though "Show all filename extensions" had been checked.

I realised that it was because I was in "All My Files" which is apparently not affected by "Show all filename extensions".

Display of the extension in "All My Files" will be determined by the "Hide Extension" setting.

When you create a new file, "Hide Extension" will be checked by default. I couldn't find whether you can change it to show the file extension by default.

Wednesday, 10 February 2016

Base Google Map

Not sure how to display a business on the default google map

It uses an algorithm to determine which businesses are displayed

I've tried

 - adding website
 - adding opening hours
 - adding photos
 - posting a review


It must be determined by the number of links to your business