Planespotting at Wellington airport on a Sunday

Planespotting in Queenstown

A definition of heritage and how it can be used without being the enemy of the living

What is the role of Heritage New Zealand?

Over the past decade, Heritage NZ has gained a reputation in Wellington as a group that would rather see a city die than consider even the smallest of alteration. When talking to friends and family there is a sense of heritage being important in spite of what Heritage NZ is doing.

What is heritage?

Plenty of dictionary definitions exist for the term heritage. Wiktionary, Merriam-Webster, Cambridge, etc. All refer to a concept of something inherited from a predecessor, a bithright.

In digging through Heritage NZ's website I found statement after statement saying that heritage must be preserved or maintained as it is important. Yet very little could be found defining what it was. Heritage New Zealand - About Us

Sections 2 and 3 of Historic Heritage Principles and Issues give definitions so large almost anything existing could be considered heritage. "Contributes to an understanding and appreciation of New Zealand’s history and cultures." is repeated in several places without giving any guidance as to where it stops. Centennial Highway without rope barriers contributes to an understanding of New Zealand's history of road safety. Auckland Airport's open air path between terminals contributes to an understanding of New Zealand's aerial connections to the outside world. Grafton Gully in Auckland contributes to an understanding and appreciation of the lengths we will go to to build motorways through the middle of a city. And the Wellington Motorway through Tinakori contributes to an understanding and appreciation of how our predecessors would happily bulldoze through poor neighbourhoods.

All these things are heritage to someone. But you would only find a few voices that would want to keep them and almost none that would want to stop them from ever changing. However the documents put out by Heritage NZ are always talking about preserving and stopping. It seems that in the mind of Heritage NZ, heritage is the stopping of time. It is the encasing of a thing in amber and never letting it change in any form.

With this working definition of heritage where does heritage start or stop? Should we move everyone out of Wellington so it will never change? What about the place where the people moved to? That will destroy the heritage of that area. Should we level all buildings in Wellington and restore it to what it was in the 1800s? Why not earlier? Why not before any humans came to these islands.

Clearly these are silly suggestions. But nothing I could find described where this limit was for heritage. It was only ever about stopping, about preserving. For who? Why?

So, what do I think is heritage?

Given the above doesn't make much sense you might think I would propose that heritage is useless. That is far from the case. While I strongly disagree with the actions of Heritage NZ, I can list off hundreds of things I think should be retained in some form. Things that need protection from total destruction and erasure from history. Yet I also think that these things should not be frozen in time. Instead being allowed to change with guidance. But I was unable to identify a reasoning of why. Why did I think some things need protection? Why did I think that these things should be allowed to change? Why would I choose some things to protect and ignore others?

It bugged me. I should be able to describe a structure to why I thought this. So I set myself the goal of assembling my own definition of heritage. To take the dictionary definitions, the copius documents from Heritage NZ, a collection of things I think are worth protecting, and just as importantly a collection of things I think are not worth protecting.

After a while of thinking. Coming up with various definitions and guiding frameworks. And throwing out one after the other as they would include or exclude important things. I came up and refined the following.

Heritage is the use of objects, physical or ephemeral, to communicate wanted history and lessons to our successors.

So what in overly broad bollocks does that mean?

Heritage is a thing. It can be a physical thing such as a piece of paper or location. It can also be something ephemeral like a story or legend. But heritage is not just a thing. Heritage is what that thing represents, a moment in history. Heritage is a way for us to connect the now with the past. It is a totem to help establish an emotional connection to who went before.

Heritage is also more than that. Heritage evolves and changes. Buildings are changed as their surroundings are changed. Once standing proud in an area they can be shrunk by the progression of time as new things rise up over them. An object that originally represented something our predecessors were proud of can become a warning or even something to be ashamed of. As our knowledge, understanding, and ethics change. A thing that survived in spite of our predecessors belief that it had no value can become a cruicial piece of heritage to connect ourselves with the past.

Heritage is a way for us to connect with the past. It is a way for us to communicate with the future. It is a way for us to identify to our successors the things that we believe they should remember and learn from.

Heritage can be represented by more than the original protons, electrons, neutrons, and quarks that it was. It is continued through stories, legends, and the memories of those that come after.

Heritage is not about freezing something in time. It is not about turning a city or culture into a museum that can never change. It is not some list that only ever grows and can never be changed. It is not tied into the atoms that first came together at the moment of time we decide was important.

Does Heritage NZ serve a role with this definition?

All of the above still requires the hard work and effort of a body such as Heritage NZ to oversee. It requires a group of people who can dedicate their time to communicate the core values of heritage, why it is important to remember and then communicate these stories to our successors. It requires a group of people who can spend time researching how best to retain the core of these messages for future generations.

I believe that Heritage NZ needs their aims clarified so that their role is communicated as a supporter of heritage and not an indescriminate killer of change. I want to see Heritage NZ provided with the funding to commission research and development of tools and technologies to restore and maintain the heritage we choose.

I want to see Heritage NZ have their actions refined and focused by capping the number of places that can be protected at the highest level. As part of this I also want to see that Heritage NZ get the funding needed to cover the costs of restoration and maintenance of these places. Not leaving it up to the whims and unfunded expectations of private owners. As a group we decide that these places need to be protected. We need to show this by providing the funding to do it.

I would adjust Heritage NZ's guidance to make it clear that safety and accessibility take precedence over purity. If a structure needs major changes or replacemant of large sections to make it accessible for all kiwis? Then it gets done. With efforts to make the design sympathetic to the existing heritage we want to highlight.

Are there examples elsewhere that we could adopt and evolve for our needs?

We are not the first country to go through this problem. Many places around the world can trace their heritage of a location back thousands of years or more. Have they come up with any approaches that we could look at adopting?

In 1866, English Heritage started the blue plaque scheme in London. Since then it has inspired the creation of similar schemes to cover the entire UK and similar schemes have been adopted elsewhere Blue Plaque Scheme. To summarazie, on buildings and locations that are tied to events or people that are important to the heritage of the UK, a metal plaque with blue enamel is affixed at the location. On this plaque the person and/or event is described. From the building containing the office in which Penicillian was first identified, to the pub where the Beatles had their first paid gig. These plaques can be found all over the UK, highlighting the knowledge that the community wants to pass on to their descendents.

Private companies have also done things to highlight items and events they feel is a part of their heritage. The crane manufacturer Libherr discovered that a crane of the model that set them onto the path of becoming a world leader in cranes, was still in use nearby about 40 years later. Not only was it of this model, it was the very first to be built. The company aquired the crane back from the operator. And then it went about restoring the machine into near new condition. To Heritage NZ this would be impossible as components were replaced with no real way to rollback the repairs. Yet at the end they had this object back to an almost new condition. Where it represents the history and heritage of all those that have worked to design and build these machines. It is ok to make permanent changes or replacements if it is done with consideration and the aim of maintaining the whole for the future. Liebherr Crane Restoration

Railway stations are full of examples where they have been majorly modified without losing the core identity of the location. St Pancras in London had the main platform area demolished during restoration. With shopping and international rail facilities placed in the original freight level and a new platform area being built for the Eurostar trains to Paris and Brussels. King's Cross station in London had a huge roof installed that turned an outside area into more internal space for shops and travellers. And Britomart in Auckland had floors demolished to provide access to the underground platforms. Each of these stations is know and recognized for the history and heritage that the original buildings represent. But that heritage value has not been used to stop any changes from being allowed. If anything, these huge changes have helped build even more heritage recognition into these places. As locations of history, of people, of stories and lessons learnt.

How can this be applied to Wellington in particular and Aotearoa New Zealand in general?

In Wellington this way of defining heritage would free up our ability to make our environment safer without being tied into a near impossible standard.

For Wellington Railway Station it would open up the ability to make accessibility into all areas a requirement. Replacing the steps with gradual ramps. Replacing the platform canopies with a full width and length canopy that covers all platforms.

For the Gordon Wilson Flats it would allow us to rebuild them with modern materials and engineering knowledge. Creating warm and safe living spaces that will build new heritage on top of the original. Evolving the heritage of the place.

With Wellington Central Library it would open up the option to build something new with current best practices for public spaces. While retaining the elements that are iconic to Athfield Architects.

We could use plaques around the country to identify the locations where important events occured that we want our descendents to remember. What exists near the old location of Athletic Park in Wellington to recognize the Springbok Tour protests? What of the small locations where events that progressed the freedom of queer communities? How can we find the places that sufferagetes made the core decisions that ended in the right to vote being expanded?

This way of thinking would create new ways of recognizing the heritage of areas without having to encase things in amber.

Heritage is important. It must live alongside the present and future without losing that connection to the past.

Heritage is important. It is vital. Heritage is the stories, the lessons, the emotions, that we tie to a place or object. It exists for us to connect with our ancestors, to learn from their mistakes and celebrate their successes. It exists to pass this knowledge on to our descendents. So that they learn from and of those that went before them.

We must not let this idea that heritage is an enemy of those that live now. Or we will fail to pass things on to our successors. Heritage helps us understand not just who we are, but how we got here. It must not be used to stop us from changing into something better.

COVID and the distribution of wealth.

With all the silly and fun comments I've made around the covid vaccination I want to make a more serious comment.

Not even 2 years ago we had a new to human infection spreading around the world like wildfire. Where our only defense was to lock ourselves away from friends and family scattered around the world. Where we had to give up our freedom to move around our home for a short while. With no cure or effective treatment.

Within those two years we have not only developed one vaccine, but several, and have tested and distributed it around the world. This is faster than any infection every before dealt with by our species.

And yet the people that have been critical to this languish whilst the wealth is hoarded and hidden from use.

Who developed and distributed the vaccine, who was the essential worker keeping the core of our infrastructure and life running? The CEO? The professional sportsperson? The actor? The landowner? The stockbroker?

No, it was the scientist, doctor, nurse, civil servant, security guard, truck driver, farmer, supermarket worker, paramedic, firefighter, bus/train drivers, refuse collectors, even cops.

We claim these groups are essential and yet we let the wealth and hard work of these people, and workers, be hoarded by the already filthy rich. Those who add take far more from society than they ever add. And benefit most from the safety and stability of an industrialized nation.

As we begin to return to a sort of normality. We should think about how we can adjust our society and economy to show that we really do value essential workers. Even if that means we personally may not have as much wealth as we currently have. Or we should stop pretending and at least accept that we want an indentured servant class.

I think we should start looking at ways to measure ourselves better against our claimed goals. Metrics like class size, cost of living compared to income, differential between those that have the most wealth and the least, etc.

Managing work distractions by trimming notifications

Notification hell

Over the past few years as I’ve moved through senior developer roles and now into a technical lead role. I have noticed my time becoming more and more disjointed. This of course made it more and more difficult to get into a zone of concentration to get pieces of work completed. It took a while but I eventually noticed that it wasn’t just the extra meetings I was attending or running. Or the extra oversight of more junior peers. Instead the largest disruption was the mountain of notifications from all the various communication applications I was connected to.

The obvious solution is to simply delete all these programs and poof, no more notifications. This doesn’t work so well if I still want to be reachable by junior peers or others that need short notice feedback or something being done. Nor could I just simply turn off all the notifications as that would create the same problem. What I needed was a process that I could apply that would allow high priority things to notify me, medium priority things to be obvious when regularly checked, and everything else to go into the background.

The rules

It took a few months but I eventually came up with a setup that works effectively for me.

What I did was to go through all my communication applications and turn off ALL notifications. From here I then applied a handful of rules to figure out the notifications I would turn back on.

  1. Do I need to respond ASAP?

  2. Do I need to respond in a day or two?

  3. Is this useful to keep up to date with?

Do I need to respond NOW?

For number 1 I thought about the scenarios I wanted to know about immediately. This basically boiled down to any message addressed to me on whatever company platform was being used for daily rapid communication. At my current workplace that meant MS Teams. So I enabled desktop notifications in Teams only for direct messages and threads where I had been tagged. All other notifications remained off. This even included email messages addressed to me. That is because email is not used as a means of fast messaging in the company.

Do I need to respond soonish?

Number 2 is for stuff like threads in MS Teams that I want to be checking regularly to provide rapid help to my team or others. And for messages that need responding to soon but are not so vital as to need handling now. This is where things like creating an email rule for any incoming email where you are not in the To line. Scott Hanselman did a blog post on this over 2 years ago and I know I had been introduced to it even earlier. https://www.hanselman.com/blog/OneEmailRuleHaveASeparateInboxAndAnInboxCCToReduceEmailStressGuaranteed.aspx I also turn on the icon notifications for when an unread email is in the Inbox. As no window popped up or sound played it does not distract me from my topic of concentration. But it does give me a flag to look for when I am ready to check things.

This flows into the next tactic which is hiding any folder, channel, or other tab you don’t need to be checking regularly. So in MS Teams this involves hiding any channel I do not want to be distracted by. It could be a channel used by another team for something not important for me, or might be a group chat that has aged out of usefulness. This can be applied to email programs like Outlook by placing the folders you want to keep track of in the Favourites section.

I will check these applications several times a day looking only for those notifications or hints.

Is this something I just want to keep an eye on?

Finally we have number 3. These could be emails where I have been CC’d to keep me in the loop, company messages about BAU topics, or communications in another team that would be useful to know about. For this I will leave all sorts of notifications turned off. But I will leave the applications running, or folders in places easy to check. I might end up checking these things once a day or only a couple of times a week.

For anything that doesn’t fall under these three rules I will seriously consider just automatically deleting them. For things like Yammer or MS Teams I will just leave the channel or group.

Since applying these rules I’ve gone from dozens of notifications distracting me every day to just a handful. And I have found that relatively few important communications slip between the cracks. You may need to go digging in the settings or do research to find all these options, but the payoff in extra concentration time is worth it.

tl;dr

So, to summarise:

  1. Turn off all notifications

  2. Then turn on specific notifications if the following rules are satisfied

    1. Do I need to respond or know right now?

      • Turn on ALL the noisy notifications. (Pop ups, sounds, animations, etc.)

    2. Do I need to know or respond within 48 hours?

      • Turn on the quiet background notifications. (Icon changes, bolder channels, etc.)

    3. Do I want to stay up to date with this?

      • Leave notifications off, but put the communications in places you will see

    4. Anything else?

      • Consider leaving or deleting

A careful gotcha when referencing VB.NET code from C#

When referencing VB.NET code from C#.NET there is a subtle but very important difference between the two.

This was found when I was trying to access some legacy VB.NET code that used reflection to interact with two classes with nearly the same name. The VB.NET code worked perfectly fine but I was faced with a compiler error when trying to call the code from a new C#.NET project.

The error to watch out for is

CS0234 C# The type or namespace name does not exist in the namespace (are you missing an assembly reference?)

This comes down to the case sensitivity differences between VB.NET and C#.NET. In VB.NET the casing on class names is not important. So a class with the name VbCasingExample is the same as the class vbcasingexample. However in C#.NET these are two very different classes as identifier casing is important.

VbCasing.PNG

Compared to

CSharpCasing.PNG

So be careful when referencing VB.NET code from any case sensitive .NET language.

Capistrano failure to deploy

Had an issue a while ago where running the capistrano deploy common would sorta run capistrano but always got the following error.

The deploy has failed with an error: No live threads left. Deadlock?

The quick and easy answer is to make sure to prefix the cap command with bundle exec. So it should look like

bundle exec cap production deploy

There is some strange behavior here that I have not found the cause of yet. Something about how bundler executes ruby scripts. So just a heads up.

Set ConformanceLevel to Auto but it is already set to Auto!?

Quick post. I'm currently uplifting an old .NET 1.1 app to 4.5 and when trying to run it was getting the following exception.

System.InvalidOperationException was unhandled by user code
  HResult=-2146233079
  Message=Token Text in state Start would result in an invalid XML document. Make sure that the ConformanceLevel setting is set to ConformanceLevel.Fragment or ConformanceLevel.Auto if you want to write an XML fragment. 
  Source=System.Xml
  StackTrace:
       at System.Xml.XmlWellFormedWriter.AdvanceState(Token token)
       at System.Xml.XmlWellFormedWriter.WriteString(String text)
       at System.Xml.Xsl.Runtime.XmlQueryOutput.WriteString(String text, Boolean disableOutputEscaping)

Upon checking my code I verified that my XslCompiledTransform had the ConformanceLevel set to Auto. However I was still getting this error.

My online searches then suggested it had something to do with the XmlWriter. However there was no clear way to find the ConformanceLevel of the XmlWriter. After a bit of digging I discovered that when calling XmlWriter.Create one can pass in an XmlWriterSettings object with a ConformanceLevel property. I added this property and passed the object to the XmlWriter in Create. This solved the issue that I encountered.

The lesson from this is not only did the XslCompiltedTransform.OutputSettings ConformanceLevel had to be set to Auto but so did the XmlWriter.

XmlWriterSettings xmlWriterSettings = new XmlWriterSettings{ConformanceLevel = ConformanceLevel.Fragment};
XmlWriter resultWriter = XmlWriter.Create(memoryStream, xmlWriterSettings);
xslt.Transform(elementToTranform, resultWriter);

Nowhere was the specific change detailed so I think this might be useful for others. Please leave a comment if you find this useful.

Creating Windows Event Log Sources from PowerShell

To help out with some logging in a recent project we needed to organise the Windows logs with multiple sources. A bit of research later and I found a nice and easy way to create these log sources from PowerShell using the New-EventLog cmdlet.

After a few iterations I also put in checks to make sure the event source did not exist before trying to create it and give the appropriate feedback to the user.

function Create-LoggingSources($loggingSources){
Write-HostIndent "Creating logging sources" 1
foreach($loggingSource in $loggingSources.LoggingSource){
$eventLog = [System.Diagnostics.EventLog]::SourceExists($loggingSource)

if($eventLog)
{
Write-HostIndent "Logging Source '$loggingSource' exists" 2
}
else
{
Write-HostIndent "Creating Logging Source '$loggingSource'" 2
New-EventLog -LogName "Sauces" -Source $loggingSource
}

Limit-EventLog -OverflowAction OverWriteAsNeeded -MaximumSize 10240KB -LogName "Sauces"
}
Write-HostIndent "Logging sources created" 1
}

The logging sources are provided in an XML configuration file. $loggingSources is in the following structure.

<LoggingSources>
<LoggingSource>Apple</LoggingSource>
<LoggingSource>Orange</LoggingSource>
</LoggingSources>

I've put together a self contained example of this script you can play with. It will create two new event log sources called Apple and Orange in the log of Sauce. CreateEventLogs.ps1

Checking if supplied domain user credentials are correct with PowerShell

On a recent project we had the problem of creating multiple Windows Services to be run under a single account. So since we did not want to store the password in source control we had our script prompt us for the password. This worked really well until one day we put the wrong password in, and since Active Directory was set up to lock accounts after three bad tries we found we would instantly lock an account every time we put the password in wrong once.

So the obvious solution was to check once that the credentials you had were right before trying to do all this work and stupidly locking an account.

Of course someone had thankfully asked this question before. And thanks to JimB on ServerFault I basically used his entire answer as it did just what was needed. Original answer on ServerFault.

function Test-Login($serviceUsername, $password){
# http://serverfault.com/questions/276098/check-if-user-password-input-is-valid-in-powershell-script
# Get current domain using logged-on user's credentials
$CurrentDomain = "LDAP://" + ([ADSI]"").distinguishedName
$domain = New-Object System.DirectoryServices.DirectoryEntry($CurrentDomain, $serviceUsername, $password)

if ($domain.name -eq $null)
{
write-host "Authentication failed - please verify your username and password." -ForegroundColor Red -BackgroundColor Black
return $false;
}
else
{
write-host "Successfully authenticated with domain $serviceUsername" -ForegroundColor Green
return $true;
}
}
 

Getting the Combination of Two ItemGroups in MSBuild

In a project recently we needed a way to generate the combinations of two ItemGroups to build a release package with folders for environments and several copies of a program within each environment folder.

As MSBuild does not have an easy way to iterate through two collections to build such a combinations we need to take some advantage of how MSBuild handles collections.

We can take advantage of this by creating a new ItemGroup using one of the ItemGroups we want to combine and creating a new property on this new ItemGroup using the collection defined by the second ItemGroup we want to combine

The below snippet shows this in action. Try it out by copying into a text file, saving it, and running it with MSBuild.exe.

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="DressPerson"
 xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ItemGroup>
<Person Include="Item">
<Name>Alice</Name>
</Person>
<Person Include="Item">
<Name>Bob</Name>
</Person>
<ItemOfClothing Include="Item">
<Name>Shirt</Name>
</ItemOfClothing>
<ItemOfClothing Include="Item">
<Name>Shorts</Name>
</ItemOfClothing>
</ItemGroup>

<Target Name="DressPerson">
<!-- Neat way to get the combinations of two ItemGroups http://stackoverflow.com/a/18032552/41492 -->
<ItemGroup>
<Combined Include="@(Person)">
<ItemOfClothingName>%(ItemOfClothing.Name)</ItemOfClothingName>
</Combined>
</ItemGroup>

<Message Text="%(Combined.Name) -- %(Combined.ItemOfClothingName)" />
</Target>
</Project>

Huge thanks to the user Dog Ears on StackOverflow whose answer put me on the right path. http://stackoverflow.com/a/18032552/41492

Remembering where you've been in Powershell with pushd and popd

The other day I discovered a long existing pair of commands in Powershell that allows one to navigate to a directory and then back to the previous one without having to manually maintain a stack of directories. The two commands are pushd and popd.

A quick bit of searching shows that these commands have existed in Unix shells for many years as well as Powershell since version 2. Wikipedia -- Pushd and popd

Where I have found this really useful recently is in deployment scripts where I need to change the current directory in the script but for usability I want to go back to where the script was first called from should any errors occur or even if the script finishes successfully. By using a try/catch/finally pattern this allows me to put the user back where they started with confidence whenever they execute the script.

try
{
pushd DIRECTORYPATH
# Logic goes here
}
catch
{
# Make sure any exceptions are bubbled up
throw $_
}
finally
{
popd
}

TechNet -- Push-Location
TechNet -- Pop-Location

Open Government Data Sets

One of the lesser known government websites that I have come across is https://data.govt.nz/

This is a site that gathers together most, if not all, the data sets offered by all the various government department. From CEO salaries, to land mapping, to health data.

In the past I've used it to find such interesting tidbits as how the median age of death has moved over time and how state sector CEO salaries have moved in comparison to front line workers.

So go browse and find interesting things and make use of the data created via your taxes.

Health, Voting, and Corruption.

Green Party Health Policy

One of the things that has made me wary of putting strong support for the Greens has always been their policy on science related topics. Whilst the Genetic Engineering one is well known their health policy was one full of anti vaccination and alt med. This was a direct result of the previous Green Party health spokesperson Sue Bradford. Since then Kevin Hague has overseen a change to this policy. The author of HonestUniverse recently got in contact with Kevin Hague to see just what sorts of support for alt med the Green Party has as part of their current health policy. A very interesting read it demostrates an interesting change in how the Green Party has changed.

Advance voting statistics

An interesting change in this election to previous elections has been just how hard all the parties have been pushing early voting. During the week the Electoral Commission tweeted a link to this page where they are tallying the number of votes per day but also compare it against the early voting period of the past two elections. The Electoral Commission does state they will update this everyday but as of this writing it seems to be every weekday. So far the uptake of early voting is already nearly 3 times compared to the same time last election. However I will find it interesting to see if this is people who do not usually vote or is it just people who usually vote on election day getting in early.

Judith Collins' office made haste on OIA

Even though Judith Collins jumped before she was pushed there are still details coming to light on the selected fast tracking of OIA requests. It does seem to be that the only OIA requests to be delivered in a reasonable time or even extremely fast time are those that covered topics that would embarass those she disliked such as the head of the SFO at the time. It will be interesting to see just what the results of all the investigations are after the election and to see just what happens to Judith Collins.

Good comments instead of bad

One of the refrains that we all hear when the topic of code comments comes up is the refrain “My code is self-documenting.” On the surface this refrain makes sense, why write more than you have to. Unfortunately the way this is usually implemented results in the baby being thrown out with the bathwater. Leaving us in a worse off position than we were with too many comments.

I’ve never met someone who would argue that the code we create should be difficult to understand. That the how the code executes should be hidden or where the flow of control goes. Our code needs to be easy to understand so that as we maintain it in the future we do not have to rewrite entire classes just to add a bit of functionality.

So, what is a good code comment?

Comments should explain WHY” to paraphrase the colleague of mine who gave me this pointer.

Code Comments

How often have you come across some code that works but does something in a crazy way when a much more simple option is clear to you? Only when you implement your simple solution suddenly bugs appear and you finally understand why those lines existed.

An example of a superflorus comment can be found in the .NET Framework Reference Source of the String class. Range check everything. Yes, I can see that’s being done. You’ve obviously thought it important enough to point out but why? Why is it important to note that you are doing all range checks? A comment like this only results in more questions while answering none.

This sort of situation is where code comments become invaluable and will save you and your colleague’s hours in the future. Spend the time to explain why you made the design decisions you did. When you apply a workaround that is strange explain why you did this instead of the more ‘obvious’ solution.

A good example can also be found in the .NET Framework Reference Source. But this time in the DateTime class. That DateTime adjustment underneath the code is not clear at first glance why you would want to add double the day remainder in milliseconds when the time is negative. However when we read the comment above it explains why we would want to do such a thing and even uses a clear example to demonstrate the way.

Commit Comments

This concept of explaining why finds even more value when it comes to commit comments.

How often do you see an odd design decision but when you look into the history of that file the comment is “Added files.” A comment like that is less than worthless because not only does it tell you nothing new but you get irritated or angry and it sits with you as you try to fix whatever is wrong. Again, explain WHY you have made the changes you have. Explain why you chose a pattern or design over another. When writing these comments imagine that 12 months from now you will be coming back to this. When we can barely remember why we made choices a few weeks ago how can we expect to remember why we made choices 52 weeks later?

So to conclude. “Self-documenting code” should be applied to only the how something works. In no way can it show the why changes were made of designs chosen. When you come back months or years later the why is more valuable than any amount of how or what comments.

Running MSTest unit tests via an MSBuild script

The past couple days I've been having fun trying to get some MSTest unit tests to be run from a MSBuild build script. This was so I could run all the tests via one build script via TeamCity without having it tied into TeamCity too heavily.

You can then use the XML Report Processing build step in a TeamCity build configuration to parse the results file and this will give you the tracking of tests.

Huge thanks to Yet Another Blog In Cyberspace for doing most of the legwork that I based my stuff off of. Running MSTest UnitTests using MSBuild

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="RunCIBuild"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MsTestExePath>C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe</MsTestExePath>
<DoubleQuotes>"</DoubleQuotes>
<OutputPath>$(MSBuildProjectDirectory)\Output</OutputPath>
<MsTestResultPath>$(OutputPath)\MyResults.trx</MsTestResultPath>
<Configuration>Release</Configuration>
</PropertyGroup>


<Target Name="RunCIBuild">
<CallTarget Targets="CompileSolution"/>
<CallTarget Targets="AfterBuild"/>
</Target>

<Target Name="CompileSolution">
<MSBuild Projects="<!--Solution file goes here-->"
Properties="Configuration=$(Configuration)"
Targets="Build">

</MSBuild>
</Target>

<Target Name="AfterBuild">
<ItemGroup>
<TestAssemblies Include="$(MSBuildProjectDirectory)\**\bin\$(Configuration)\*.Test.dll"/>
</ItemGroup>

<PropertyGroup>
<MsTestCommand>"$(MsTestExePath)" @(TestAssemblies->'/testcontainer:"%(FullPath)"', ' ') /resultsfile:"TestResults\Results.trx""</MsTestCommand>
</PropertyGroup>

<Message Text="MsTestCommand: @(TestAssemblies->'/testcontainer:$(DoubleQuotes)%(FullPath)$(DoubleQuotes)', ' ')"
Importance="high"/>

<RemoveDir Directories="TestResults"
Condition="Exists('TestResults')" />
<MakeDir Directories="TestResults" />

<Exec Command="$(MsTestCommand)"
ContinueOnError="true" />
</Target>

</Project>

2012 GN125H For Sale

Time to upgrade to something with a little more grunt. That means my little GN125 is now surplus to requirements.  Get in contact with me at James@TheFlightlessGeek.co.nz if you would like to purchase the bike.

This is a great commuter and learner bike. I've managed to reliably get 2.5L/100km around Wellington streets. Handling around town is light and easy. Super simple to maintain as well.

Comes with the pictured saddle container. 

Only a couple of scrapes and a cracked right wing mirror from one low speed spill. See attached pictures.

 

2012 GN125H   

Odometer: 4,090km

Registration: Valid through to 3/3/2014

WoF: Valid through to September 2013

 

Asking price: $1,700