The coding blog of Alastair Smith, a software developer based in Cambridge, UK. Interested in DevOps, Azure, Kubernetes, .NET Core, and VueJS.
I’ve started using svn:externals definitions to manage my libraries and tools like NAnt and NUnit. In the words of the SVN Book:
The convenience of the svn:externals property is that once it is set on a versioned directory, everyone who checks out a working copy with that directory also gets the benefit of the externals definition. In other words, once one person has made the effort to define the nested working copy structure, no one else has to bother—Subversion will, after checking out the original working copy, automatically also check out the external working copies. Ben Collins-Sussman, Brian W. Fitzpatrick, C. Michael Pilato (2002). Version Control with Subversion. Sebastopol, CA: O'Reilly Media. 155.
This works well for me: my external dependencies are versioned by Subversion, and are automatically downloaded/updated with my working copy of the current project once the externals’ definition has been created. It’s pretty painless. I did hit one bump today, however, when setting up my repository for my web frameworks’ evaluation, and here I’ll detail how I got over it.
Following on from a recent comment discussion, I'm taking on a small project to evaluate a number of the major web development frameworks currently available. I've settled on a very simple blogging system as my sample project, with a common MySQL backend. In this first post of the series, I set out the terms of reference for the evaluation, including the (very basic) requirements for the sample application.
Having been with Citrix for over a year now, I’ve got a good hold on my job as a professional software developer, and an idea of what I’d be looking for if I were to start looking to move to another company. As I’ve learnt more about the role (albeit specific to Citrix), I’ve occasionally found myself thinking, “that would make a good interview question”. Note that I’m talking here about questions from the interviewee rather than for them. I’ll go over some advice that I’ve found previously, and present some of my own questions based on my new-found experience. And, of course, you’re welcome to submit your own suggestions by commenting below.
I’ve been doing a lot more JavaScript development at work over the last few months, working on a site that is AJAX’d up to the hilt. Everything’s done with fancy jQuery effects and asynchronous calls back to the web server. The page in the browser literally never reloads.
Something that caught me out today: there’s no String.equals(String)
in JavaScript. My first thought was “what kind of half-baked language doesn’t provide an equals method for strings?!”. Then it occurred to me that select isn’t broken (or “Horses, not Zebras”). Hell, I’ve been doing Java and C# for so long now, that I’d forgotten that most times you can just do "string" == "string"
and you don’t need .equals()
.
“Select isn’t broken” is Tip No. 26 from The Pragmatic Programmer, an excellent book for professional devs that is on quite a few “must-read” lists. If you’re a dev and you haven’t read this book, do so; although some of it is starting to look dated, and a chunk of it is pretty *nix-oriented (but not specific to those platforms), it’s one of the classic texts that helps you look at your job in a different way. I found it quite an enlightening read, and it’s relatively cheap on Amazon.
My new favourite resource for development-related questions, StackOverflow.com, already provides a number of answers to this. However, I’m interested to hear from you, my small community of readers, what IDE you use for PHP development, and why you like it.
As I mentioned in a previous post, I’ve been suffering quite badly from trackback spam. I dread to think what it’s done to my Google ranking (and related search terms), and what impact it’s had on my bandwidth consumption.
As you may have noticed, I’ve not blogged in a while. The good news is, I’m back! :-)
Unfortunately, over roughly the same period, I’ve not really been keeping on top of clearing out my trackback spam, to the point where I deleted in the region of 1000 spam trackbacks this evening. Short of disabling the trackback function (which I don’t really want to do), I’m after a bit of advice on combating trackback spam.
Oddly, I don’t have any problems with comment spam at all.
Comments welcome, as always! :-)
Quantum Computing (basing computer processing and storage on subatomic particles, rather than discrete voltages) has long been hailed the next big step in computer science. Exploiting the “weirdness” of quantum mechanics offers huge steps forward in parallel processing and cryptography, but progress has been slow. After all, it’s not easy pinning down a single photon, electron, or other particle, and getting it to obey your every command. To be honest, it’s a bit like herding cats.
Enter Chaotic Computing. As featured in the current issue of the New Scientist and available online here (subscription required), this relatively new field promises similar progress to Quantum Computing with a fraction of the overhead; chaotic circuits can be easily built with today’s technology.
[img_assist | nid=50 | title= | desc= | link=node | align=center | width=450 | height=300] |
I randomly came across this earlier this evening: a Cruise Control.NET gadget for the Vista sidebar!
I’ve recently started reading Kent Beck’s excellent book Test-Driven Development by Example at work as part of my self-development goals for this quarter. Test-Driven Development (TDD) is something that I’d heard about, and knew the basic principle of (write the unit tests first and write the code to pass them), but had never tried or bothered to read up on. There’s an emphasis in our team at work on moving to a more agile way of working so that we can better respond to the different demands of the two products the Web Interface supports: Citrix XenApp and Citrix XenDesktop. It’s one of those changes that is more easily talked about than accomplished, and for a while at least it will be mostly talk. However, TDD seems to fit in quite nicely as a halfway house between our current development practices and a fully agile environment: we (obviously) currently write unit tests, although our test coverage is possibly lower than we’d like; TDD isn’t explicitly agile, being an implementation method or coding technique rather than a project methodology. In short, it would be a small step to move from where we are now to now + TDD, and then (hopefully) an easier step from now + TDD to “agile”.
But enough about Citrix and back to the book and TDD. The book is written in four sections: an example application developed using TDD; an introduction to the xUnit frameworks (specifically JUnit); an introduction to design patterns; and an introduction to re-factoring. The last two may initially seem incongruous, but re-factoring is a core part of the TDD mindset; design patterns provide “template” implementations for common problems which speed up your coding and are proven quantities (and thus are easier to test). The example application (multi-currency money support) is actually a good example, being simple enough to understand in a single a concept, and yet complex enough to make an interesting exercise.
Beck walks through the example in a series of 10 or so chapters, adding roughly one new test per chapter and implementing the code that will be exercised by the test. Each chapter follows the TDD cycle of:
This is repeated until the component is finished, and is begun again each time new functionality is added to the component.
One of the (many) great things about TDD is that because you write the test first, you automatically produce the simplest, most useful interface to your classes. For example:
That’s right folks, TDD makes you write cleaner code!
The tests continue in a similar vein throughout this section, with the code being implemented in parallel. With that in mind it really is best to implement the code samples as you read. I didn’t do this, and regretted it by the end of the section, as some of the tests and changes had got quite complex.
Another good thing about TDD is that you instantaneously get near-100% code coverage. As is customary to mention at this point, coverage is no indicator of product or code quality, but it is a useful statistic for identifying “holes” of code that isn’t tested at all.
The book is well-written: a good sense of humour pervades throughout the text, without getting in the way. Unlike Don’t Make Me Think!, it is not littered with footnotes.
I knew before reading Test-Driven Development by Example that TDD was good, and I ever so vaguely knew why (it gets you writing unit tests!), but I hadn’t grasped just how good it actually is. I’ve quickly become a bit of a TDD evangelist, and I most certainly will be looking to make use of it in my next task at work (it’s too late for my current task to get any real benefit from it). It’s also got me thinking about unit testing our JavaScript code (JsUnit looks like a good start), as we make heavy use of this and it currently has low unit test coverage.
If you’re not already using TDD, I strongly recommend looking into it for your own projects — be they private home-brew projects or tasks at work — and buy a copy of this book as an introduction.
Stack Overflow, as I mentioned in my last post, is a new community site developed by Joel Spolsky and Jeff Atwood aimed at enabling developers to to help each other. Much like asking a question of a trusted friend or colleague (but with 5,379 to call on), there are no holds barred on the questions that you can ask. Even questions that you think might be “dumb” questions are tackled. For example, my curiosity was piqued by enums and whether values could be added to them dynamically. I already knew to a certainty of roughly 98% what the answer would be, but I asked it anyway. As it turns out, two people thought it a “good” or “useful” question, too, and it picked up nine answers. My community reputation is now pushing close to the magic 100 mark, when I can start down-voting questions and answers.
I recently posted a question to Stack Overflow. This is a great developer community site run by Jeff Atwood and Joel Spolsky that’s currently in private beta. It’s a good mixture of discussion forum, Digg-style ratings’ site, and wiki that promises to become a truly invaluable resource once development is complete; it’s well on its way already! The idea is that ordinary developers post questions and the community responds, with both questions and answers being voted upon by the community.
I’ve included my question below to gain the issue a bit of extra exposure. If you have a stackoverflow.com account, please visit my question and post a response there, or vote on the question and any existing answers. Alternatively, please leave a comment on this post with your thoughts.
Batman Forever (1995) screened on Channel 4 last night. Having not seen it in many years and having The Dark Knight still relatively fresh in my mind, it was very interesting watching it again and comparing the tone of the two movie series.
I’ve come rather late to the Design Patterns ball; unfortunately it wasn’t something that got taught at Warwick (although that may have changed with their new CS course), and so it wasn’t until my final year that I even heard of these patterns.
I am slightly embarrassed to admit this, because they’re a pretty fundamental part of programming (or, at least, programming in a DRY manner) and the CS education I received from Warwick was in most other respects first class; it’s just that they didn’t really cover much in terms of “real world” programming techniques. The emphasis was (rightly, in my opinion) always on teaching the fundamentals and the underlying theories, rather than teaching us how to code Java. For example, we didn’t get any suggestions on good UI design and implementation, but we did get a course on Human-Computer Interaction which was much more wide-ranging and interesting (gotta love Psychology :-).
Design Patterns provide ready-made solutions to a number of standard programming problems, and in this first post in a series of as-yet-unknown length I will investigate the Abstract Factory pattern.
To aid the testing of my personal finance program, I’ve been making heavy use of the NMock mocking framework for .NET. This is a cool utility that allows you replace actual code calls with mock code calls, factoring out a lot of complexity of setting up some tests. For example, I first started using it to mock the log4net logging framework rather than creating a new logger for each test/suite and passing that around. More recently, I’ve found it useful in mocking parts of the plug-in framework that are required by the code but not part of the test (such as the preferences’ manager, for example).
.NET format strings rock. These are roughly equivalent to the old-school C-style sprintf() functions, with their %d
, etc., symbols. There’s some serious power to these strings, however; think PHP’s date() function on acid, and for more than just dates.
None of this is likely to be new to all but the greenest of .NET developers (like me), but it’s always worth reminding yourself of how great these things are.
[img_assist | nid=36 | title= | desc= | link=node | align=none | width=400 | height=407] |
I’ve recently been reconfiguring my home network to utilise a Windows domain. As I’ve improved my home development environment, I’ve started needing to make greater use of network shares and things, and running a mixed-OS environment as I do, I have inevitably run into some problems with credentials. This is the first post in a two-part series; this post will describe my initial experiences configuring my domain, whilst the second post will focus on getting Ubuntu and Fedora Core 7 talking to my domain.
I’ve recently reconfigured my home network to utilise a Windows domain. As I’ve improved my home development environment, I’ve needed to make greater use of network shares and things, and running a mixed-OS environment as I do, I have inevitably run into some problems with credentials. This is the second post in a two-part series; the first post describes my initial experiences configuring my domain, whilst this post will focus on getting Ubuntu and Fedora Core 7 talking to my domain.
I’ve been told a few times in the past (and, surprisingly, a couple of times fairly recently) that I look like Leonardo DiCaprio. I don’t see it myself. [img_assist|nid=30|title=Me, Alastair Smith|desc=|link=node|align=left|width=150|height=200][img_assist|nid=31|title=Leonardo DiCaprio|desc=|link=node|align=left|width=122|height=200]
[5/5] This is a truly excellent movie, and a fitting sequel to 2005's Batman Begins. It is much darker, more raw and more visceral than the first four Batman films, as we have come to expect from Christopher Nolan, and you will be reflecting on the movie for days afterwards. The superhero movie has this year come of age, and The Dark Knight is the best example yet of how a superhero movie can be a damn good piece of cinema too.
As a follow-up to my previous post on message passing in a plug-in framework, I thought I’d post my solution to the problem. Now that I’ve finally reached a solution, that is…!
[Note: It would be worth reading the first post to get an idea of what I was trying to do. ]
[img_assist | nid=26 | title= | desc= | link=node | align=none | width=480 | height=318] |
So my promised updates on other things haven’t quite come to fruition… This week’s been kinda busy.
But this evening I sat down with NAnt and NUnit to try and get my Unit Tests working under NUnit and running from the automated NAnt build, and, six hours later, I’m still here.
[img_assist | nid=21 | title= | desc= | link=none | align=center | width=427 | height=640] |
Following up on last night’s NUnit Headaches, I managed to solve the problem in a relatively short amount of time.
Closer inspection of the error message received revealed that the nunit.framework DLL could not be located. Adding nunit.framework.dll and nunit.core.dll to the GAC fixed this. My impression was that the installutil .NET tool did this for me; turns out that’s not the case, and I needed the gacutil tool in the Windows SDK instead.
Now I just have to work out how to resolve the same error with the DLL under test without adding that to the GAC as well. Maybe then I can fix NUnit in the same way and uninstall NUnit from the GAC.
I finally resolved my NUnit headaches. Turns out the aspirin I needed to was to RTFM and continue to the next step of Jean-Paul Boodhoo’s guide to NAnt.
[img_assist | nid=24 | title= | desc= | link=url | url=http://en.wikipedia.org/wiki/Aspirin | align=center | width=500 | height=400] |
Had I done this before, I would have realised that in order to get NUnit working in the manner I wished, I needed to copy the NUnit DLLs either to the GAC or to the build staging area so that they resided in the same directory as my Unit Tests’ DLL. The latter is the preferred method. I would also have learned that I needed to copy any other dependent assemblies, such as log4net and NMock as part of the build process.
Jean-Paul Boodhoo put together a very clear and concise introduction to NAnt back in 2006. It's helped me no end converting a couple of my projects from Visual Studio Ctrl+Shift+B/MSBuild to NAnt today; I heartily recommend it as an introduction to NAnt. You can find the index to the series at http://blog.jpboodhoo.com/NAntStarterSeries.aspx.