Stew's CodeCave

Recent posts

Automated Testing - Page Objects

Created by Stewart Platt at 2015-05-09 14:42:24.869826

I love Page Objects, however I dislike the name.

With the page object model, we encourage abstraction of the DOM (or whatever locators you might use for functional UI testing). This is a good thing (TM).

Unfortunately, the term Page Object doesn't convey the benefit of modelling applications at a more granular level. Code reuse and encapsulation does not begin and end with pages.

Rather, individual components should be modelled where appropriate. One should not rigorously apply DRY principles to plain English test cases (for Cucumber/Gherkin fans out there), but backing code sure as Hell warrants it.

If you've used page objects (or some similar abstraction), you're a cut above the rest, but please, don't take the name too literally. Feel free to model smaller components.

More ...

JSPerf: Favour prototyped object over module pattern?

Created by Stewart Platt at 2014-01-18 21:44:05.863735

Learning more about optimisations in v8...

Using the = (function() { return {}; })(); notation:

[stew@filth nora]$ node Wink.js
[stew@filth nora]$ node Wink.js
[stew@filth nora]$ node Wink.js
More ...

Validating a refactor

Created by Stewart Platt at 2014-01-18 20:31:29.394888

Goodbye JS closure, let's use some prototypes.

Does the performance benchmark still work?
Good enough for me.

I am not a professional.

Optimising JavaScript for v8

Created by Stewart Platt at 2014-01-18 19:55:50.290984

I hope I'll do a couple of these posts as I learn more, because writing fast code in C/C++ appears to have almost nothing to do with writing fast code in JavaScript.

Writing a BitStream in pure JS I tried the following operation:

// Calculate the number of bits to write in this 
var bitsToWrite = bitsLeftInByte < bitLength ? bitsLeftInByte : bitLength;

On my first round of optimisation, this seemed like a possible candidate.

Math.min(bitsLeftInByte, bitLength);
More ...

Efnet bans Hetzner IP space

Created by Stewart Platt at 2013-04-09 00:45:53.515670

Casually idling on Efnet when...

stew [] has quit [Due to abuse Hetzners IP space have been 
banned on this server. Please contact (2013/4/8 20.11)]

I'm not sure what's going on here.

Update 10/04/2013:

As this was a K-Line, I reconnected via another server. Some time later I was, again, banned.

More ...

A sound breakfast strategy

Created by Stewart Platt at 2013-03-25 00:38:48.040543

Kellogg's must have a game theorist in their product development team.
It's the most important meal of the day, so minimise your maximum hunger today!


Game Closure's DevKit and Ubuntu 12.04

Created by Stewart Platt at 2013-03-23 18:14:31.361502

Game Closure have recently released an Android and iOS development kit for producing games using HTML 5 and Javascript.

Presently, they only support Mac OSX, but I played around and got it reasonably happy running on an Ubuntu 12.04 VM I had laying around.


$ # You will need git if you don't already have it
$ sudo apt-get install git

$ # Install java (Not tested yet)
More ...

Amazon S3, Cloudfront and caching issues

Created by Stewart Platt at 2013-03-20 02:19:48.438570

I recently hacked together a project prototype using Amazon Web Services.
I store various files using Amazon S3 and access them via Amazon's Cloudfront service.

In my case, Cloudfront adds very little to the solution other than leaving me free from worrying about catering to multiple regions in the prototype. This is because in ideal operation of the system, each file should be fetched once and only once, barring exceptional circumstances. All other requests for the content would be expected to return a 304 (Not modified) response.

I currently use an If-Not-Modified header to perform cache control, which for the most part works well. However, every now and then Cloudfront insists on returning a full 200 response, despite the ETag matching exactly.
This happens maybe once in 100 times on smaller files. Although I haven't been able to test this in more depth, I suspect it happens more frequently with larger files.

stew@raspberrypi ~ $ grep -c "not modified" Update.log # Number of 304s
More ...