Tuesday, October 25, 2011

Tue 25th October

Late one last night so late start today. Things are starting to take shape.

It’s all working quite nicely. Now writing a crapload of unit tests. Got to start looking at mocking in JavaScript.

A few tests now written, including some against the navigation pubsub stuff. Works out alright! Haven’t tested most of the navigation module as the meat is in private functions and the output is manipulation of the DOM using jQuery. Two potential approaches – mock jQuery so we can ensure the right calls are made, or render the actual HTML in the test, allow navigation to manipulate and test the resulting changes to the DOM, more like an integration / functional test. Oh… A third option is to make the methods in question public.

I intend to investigate both. The latter is probably easier in some ways and I intend to do this anyway at some point. A problem with this is getting the jQuery templates (or knockout templates / control flow bindings – more on this in a sec) into the QUnit test fixture, without copy and pasting them. They can be loaded by AJAX fairly simply, but QUnit won’t be run from a web server. Trying to load the from a local file but running into cross-domain issues. There may be some hacks to allow this - http://stackoverflow.com/questions/4208530/xmlhttprequest-origin-null-is-not-allowed-access-control-access-allow-for-file).

Since jQuery templates are being discontinued, I’ve also been looking at knockout control flow bindings. This should allow me to do away with an external templating solution and also enables the template to be written as a single template, rather than a separate, small template wherever a foreach is used. Should be much more elegant!

Enough for now. ZZZzzzZZzzzzzzzZzzzzzz…zzz….z………z……

Mon 24th October

A bit of a late start today. Slept in a bit due to being fairly sore from riding yesterday, spent a bit of time giving the olds’ cats some company.

I was hoping to get the score sheet fairly well finished today, but grappling a bit with some design issues. I want to keep navigation across the sheet as decoupled as possible from the model itself, but the navigation obviously needs to be able to identify individual balls. I could

  • handle the visible selection and deselection of balls part of the model (have a property on each ball to indicate if selected and bind a css class to this) and raise events to do this from the navigation module,
  • use jQuery to do the visible selection and deselection. This means the navigation module needs some way of identifying the HTML element for each ball, such as through the ID of the element (this would mean the template for each ball needs the context of what over, batter, inning and team it belongs to).

Either way, handling a click event on each ball element needs some way of identifying the individual ball. Ho-kay! Rethink required.

Did a bit of research into templating engines, which led to another potential JavaScript framework. It appears jQuery templates are being discontinued, with the responsibility of a templating solution being handed to the jQueryUI team. A likely candidate to supersede jQuery templates is JsRender, according to http://www.borismoore.com/2011/10/jquery-templates-and-jsviews-roadmap.html. Should be a fairly straightforward port to use them if they do become the “official” templating engine, supported by both jQuery and knockout.

This led to looking at JsViews as a potential JavaScript framework. I didn’t do much research into alternate frameworks, mainly because knockout seemed to be such a good fit for the project. While they could certainly do the job, judging by the ToDo sample application (http://borismoore.github.com/jsviews/demos/step-by-step/10_todos.html), knockout would appear to be a much more elegant solution, particularly with its dependentObservables and mapping plugin.

Friday, October 21, 2011

Fri 21st October

OK, so bending my head around the JavaScript “this” keyword. Have to use a closure every time we want to use “this” from an internal function.

Not such a productive day. Gym, stop off at olds, general stuffing around. Learned some valuable stuff about JavaScript, though, all is not lost. Nearly time to go to the pub anyways.

Thursday, October 20, 2011

Thu 20th October

So it looks like my previous employer got my pay right after all. My mistake!

Things are going well. Greatly enjoying learning JavaScript and progress on the actual project is also quite good. More unit tests! A pub sub mechanism for JavaScript will be next big cab off the rank, then finally some Azure stuff. Noice.

QUnit tests running on TFS build are no longer reporting their results correctly. Got to replace my implementation of NUnit on TFS Build with the Community TFS Build Extensions version, hopefully will fix it and also be a simpler implementation.

Got to sort out a decent backup mechanism, don’t think Live Mesh will cut it for much longer.

Anyways, off to feed ma and pa’s cats while they’re away and then for dinner with the missus.

Good times!

Wednesday, October 19, 2011

Wed 19th October

NQUnit looks sweet, should be able to get CI going without too much hassle. Resharper has a few problems refreshing the list of tests, got to sort that out (not using Resharper QUnit integration).

My previous employer didn’t pay me my entire salary for last pay. I think they ignored annual leave. Will have to chase this up. Damn corporations!

Got NUnit running on the build server (http://danderson00.blogspot.com/2011/10/running-nunit-tests-under-tfs-build.html). Also got QUnit tests working, soon to be blogged. Some notes:

Now trying to get my Windows Phone 7 tasks app building on the build server. Some missing SDKs, potential NuGet issues. A pre-build step in each project with NuGet references is a potential solution, just to call NuGet, pointing it at the packages.config file (http://www.pandincus.com/blog/combining-nuget-with-team-foundation-build).

Some stuffing around to get the Windows Phone SDK to install on Windows Server 2008 R2 - http://blogs.msdn.com/b/astebner/archive/2010/05/02/10005980.aspx.

Thinking about some interesting consequences of rendering a view from a model using knockout. Pretty tightly couples your view to your model. Definitely affecting how batter totals and over totals will be set up. Humm…

Tue 18th October

Internet is down this morning. iiNet are actually acknowledging this in a phone message on their support line, rather than treating me like a retard. Going to the gym while they sort their shit out.

Back from the gym. Internet is still down. Had some ideas on the layout, setting it out on paper is probably a good approach. Figuring out where to put float, clear and position CSS attributes is difficult! I really need to do some HTML/CSS tutorials and learn this stuff properly.

Got the layout fairly well sorted. Float: left and clear: left are well used. Not 100% sure if this is the best approach, but it works reasonably well.

Investigating extending JavaScript arrays for aggregates such as sum (obvious use is in totals). Going to create a new project containing JavaScript extensions for general purposes such as this. Now is the time to start learning JavaScript unit testing!

Looking at QUnit. Looks fairly mature. Definitely no out of the box CI integration. Some thoughts on this:
• NQUnit!
• Create an automated UI test to load the test page into a browser and fail on some failure indicator
• http://www.henrycordes.nl/post/2011/04/25/Javascript-Unittest-in-build.aspx
• http://stephenwalther.com/blog/archive/2010/12/20/integrating-javascript-unit-tests-with-visual-studio.aspx
• http://twoguysarguing.wordpress.com/2010/11/02/make-javascript-tests-part-of-your-build-qunit-rhino/
• Custom framework – use some sort of tag (“///Test”) before function declaration to denote test and call method using JScript, V8, Rhino, etc

Mon 17th October

Continued looking at knockoutjs. Lots to learn about JavaScript! Having trouble defining classes with dependent observables referencing observables from the same class. Looks exactly like the tutorial, but doesn’t work. Bah! (pass in the observable target, doofus)

Live Mesh doesn’t seem to play the game when it’s running as a service.

HTML and CSS layout is SO unintuitive.

First week (Tue 11th – Fri 14th October, plus weekend)

First week of leave. Mostly spent finishing off infrastructure. Wins included:
• Infrastructure
o Configured SMTP server for relaying through gmail account
o Configured RAID failure alerts through above SMTP server
o Configured TFS backups, including alerts through above SMTP server
o Configured Live Mesh / SkyDrive backups
o Configured web deploy agent on APPS
o Installed LiveMesh as a service
o Configured network printer
• Development
o Completed quick and dirty tasks app, deployed to phone and server
• Learning
o Started looking at knockoutjs
o Started looking at TFS client object model

Welcome

So I decided to keep a journal of the progress of Your Cricket Stats. There's nothing interesting here, why are you reading it? Go do something constructive! More technical posts are on my main blog, http://danderson00.blogspot.com/.