Gilded Rose reflections
A few days ago I linked to the talk All The Little Things by Sandi Metz, which is about about creating small objects while programming, using the Gilded Rose kata as an example.

It makes heavy use of refactoring under test driven development (TDD), of which more later.

Of course, it infected me too, and I had to have a look at it.

First, I'll admit, having seen Sandi's talk, I am completely indebted to her for having seen through to the core of the problem, and outlining a strategy of isolating the special cases as being the key to solving it.

Also, while I don't identify as being boolean-impaired, I still find the original code a little intimidating. So, I decided to try and do my refactoring in as stupid a manner as possible, learning only as much as I needed to as I went, and only trying to understand the labrynthine conditionals when it became necessary.

So, I grabbed a copy of the kata from the internet.

Original codeCollapse )
Now, because "Aged Brie" is the first case mentioned in the code, that's the one I'm going to factor out first. The way I'm going to do that is to use an "if" to create one code path for "Aged Brie", and the "else" for everything else, and then I'm going to put all the code in both halves of the if statement:

Double troubleCollapse )
OK, that's a lot of code. The thing is, now I can simplify the first half because I know that items[i].name is always "Aged Brie", and I can simplify the second half because I know that items[i].name is never "Aged Brie". So there are places I can cut clauses out of "if" statements, places I can remove the "if" statement leaving just the body, places I can delete entire "else" clauses, et cetera...

Mmmmm.....brieCollapse )
Not bad. Now I can do the same thing with "Backstage passes". Create a new clause in the "if" chain, put all the code from the "else" statement in there, and then simplify both pieces:

Backstage passes!Collapse )
From there, even for those who are boolean-impaired, it's not that hard to figure out that no changes ever happen for "Sulfuras". Still, I'll add a new clause, copy the code and simplify as before, to get the "final" version of the code for this post:

Code CompleteCollapse )
Note that I did all that without really needing to understand what those massively nested "if" statements were doing, or even understanding what any of the tests do.

I just had to copy code, reduce some "if" clauses to "true" or "false", and then cut away code which was obviously useless or unreachable. If I had tests (the version I found didn't have any, unlike Sandi's) then they would be useful to ensure I hadn't made a stupid mistake. But I didn't need them as a guide to writing any new code.

Obviously, there's more work that could be done. The "x = x - 1" can be made more readable by transforming it to "x -= 1", some of the nested "if"s can be simplifed by using "&&", and if you wanted you could move the body of each case into its own function (or object). But right now the code is tractable, and adding "Conjured" is a case of following the new pattern.

And if that were it, my curiosity would have been satisfied, and you wouldn't be reading this.

But...Collapse )

It's normally a mistake to rewrite from scratch, unless you really understand what your code is doing, and why. Even if you have good tests. Good tests can be a massive help, but they can't save you every time.

This equine corpse is not yet a pulpy mush; must be beaten again.
Although, fittingly, this article is actually a post-mortem.

Why the Vivaldi tablet never came to market
All in all, Seigo found the effort to launch open hardware devices "amazingly stressful at times." Yet, asked if he would consider another effort, he replied, "Crazily enough, yes." He would currently be unable to finance it to the extent that he did MakePlayLive, but he would definitely like to try again. "Beyond all other things, I really hope that people see what we did as evidence that it is worth trying, rather than taking it as a lesson that it can't be done."

Vantablack, the blackest black. (Ultrablack, part 7)
Scientists develop a material so dark that you can't see it...
A British company has produced a "strange, alien" material so black that it absorbs all but 0.035 per cent of visual light, setting a new world record. [...] It is so dark that the human eye cannot understand what it is seeing. Shapes and contours are lost, leaving nothing but an apparent abyss.

(via /.)


One step closer to properly reusable spaceflight...
...and not that strip-down-and-rebuild-the-whole-engine-and-go "reusability" that the Shuttle had, but a proper refuel-and-go system.

SpaceX Soft Lands Falcon 9 Rocket First Stage
This test confirms that the Falcon 9 booster is able consistently to reenter from space at hypersonic velocity, restart main engines twice, deploy landing legs and touch down at near zero velocity.

If this can cut their current launch costs by 90% as they predict (it gets so much cheaper when you don't have to build a new rocket every time) then a new era of proper space exploration could be nearly upon us...

BBQ Aftermath
First, huge thanks to everyone who turned up, and ate food, and drank drinks, and sat around chatting and having a generally relaxed time. I really enjoyed the afternoon because you were there.

Thanks also for the food and beer that was left behind. They've been yummy. :-)

However, I seem to have gained two 35cm metal kebab skewers with looped ends, and one 16cm translucent white plastic bowl/container. If these sound like escapees from your kitchen, let me know, and we can arrange to rehome the prisoners at some later date.

Plus, I have defeated all the tidying, and the large items of washing up. Just a few dozen mugs, cups and glasses to go now...

Vivaldi no more :-(
So, Improv, and by association Vivaldi tablet, project, is apparently dead. Which means my search for a fully Free-Software phone/tablet is one avenue down.

According to an email by project leader Aaron Seigo:
This entire project is on hold indefinitely. That has been noted on the MPL forums as well; we haven't been keeping that secret. The tablet project stretched out much longer than it should have and exhausted my resources in the process,

News to me, even though I'd been following the Vivaldi threads at the MLP forums, of which there were (at my last count before the site disappeared) about 3 - none of which had been posted to in months - and I didn't see anything about that at all.

So, there's the Blackphone which looks interesting. Although it was meant to be shipping, with the ability for non-pre-orderers to buy one "in June 2014", but that's not happened yet. Plus, there's suspiciously little information about the OS stack it's running on, other than it's called PrivatOS, and is a modified version of Android. No mention as to whether they've got rid of all the binary blobs and managed to get a fully-auditable Free Software stack through the bootloader, kernel, drivers and display manager, which is something I'd have expected them to shout about if they'd actually done it.

I don't think any of the FirefoxOS devices are any better, either.

The PiPad is looking good now that the specs are open and progress is being made - if only I had the copious spare time I'd need to muck about with that sort of thing.

Which mostly leaves the Nexus 7, now that the Freedreno driver seems to be doing well, which I think is the main blob that was missing an open replacement there.

Unless anyone else knows of another smartphone/tablet running a full Free Software stack? Anyone? Anyone?

Quick reminder, BBQ at mine this Saturday. Open invite to anyone I know, and your hangers-on, from about 4pm-ish, aiming to be cooking from 5ish.

If you would like to bring pig-derived BBQables, in memoriam of my home village pig roast that is no more, that would be appreciated, but it is definitely not required.

Note that if you were thinking of driver over, having a couple of drinks, finding an alternate way home, and picking your car up on Sunday, that's going to be near-impossible because of Tour de France road closures between 9am and 7pm on Sunday.

Happy Summer Solstice Everyone!
Have a great summer.

World Cup overload antidote - inside the FIFA sausage factory
Last Week Tonight with John Oliver: FIFA and the World Cup

Edit: Bonus comic: For a non-sports person, this is sorta what it's like to be on the internet right now.

And because this hadn't got around as many people as it should have, here's him weighing in on the USA's ongoing attempts to screw up The Electronic Cat Database: LWTwJO: Net Neutrality

Bonus link: John Oliver Crashes FCC Comments System After Net Neutrality Segment.

Snowden and the Future
I recently ran across this series of lectures by Eben Moglen - who was part of Phil Zimmerman's Pretty Good Privacy legal defense team against the US govt., and helped write the GPLv3 for the Free Software Foundation.

It's generally interesting if you're particularly concerned or interested about privacy, government spying, how we got here, and where we're going in the wake of Snowden's revelations, but Part III - The Union, May it be Preserved contains some of the clearest and most insightful thinking on the subject of the nature of privacy on the Internet that I've read in a long time. If you're only slightly concerned or interested about privacy, I think it's worth checking out.

we can decompose “privacy,” the concepts that we float around under that word, into three more specific parts: First, secrecy: that is, our ability to have our messages understood only by those to whom we intend to send them. Second, anonymity: that is, our ability to send and receive messages, which may be public in their content, without revealing who said and who listened or read what was said. Third, autonomy: that is, the avoidance of coercion, interference, and intervention by parties who have violated either our secrecy or our anonymity

Strangely, despite generally having no problem with reading long tracts of text on a computer monitor, I preferred watching the videos in this case. Despite Mr. Moglen's eloquence sometimes interfering with his clarity; his slightly irritating habit of turning away from the microphone and tailing off towards the end of a sentence only to turn back towards it and begin another with vigour in a way that makes it feel like he's started SHOUTING; and of course their sheer length, the videos do add a compelling dimension to his treatises.