Phillip Trelford's Array

POKE 36879,255

TickSpec dependency graph

Scott Wlaschin has just posted a really interesting series on Dependency cycles over on the F# for fun and profit site. The last post shows cycles and modularity in the wild comparing open source C# and F# projects including SpecFlow and TickSpec which have almost identical functionality,.

Here’s the dependency diagram for SpecFlow (C#):


and for TickSpec (F#):


They both have very similar functionality and in fact TickSpec implements it’s own parser too. Read Scott’s article to better understand why such large differences exist between C# and F# projects.

Same Same

After a while websites start to look the same:

every-damn-website Af

And most websites use the same server-side programming language:

Server side programming languages

And the other programming languages look the same.


PHP supports classes these days:

class Person {
 public $firstName;
 public $lastName;
 public function __construct($firstName, $lastName = '') { //Optional param
  $this->firstName = $firstName;
  $this->lastName = $lastName;
 public function greet() {
  return "Hello, I’m " . $this->firstName . " " . $this->lastName . ".";
 public static function staticGreet($firstName, $lastName) {
  return "Hello, I’m " . $firstName . " " . $lastName . ".";
$he = new Person('John', 'Smith');
$she = new Person('Sally', 'Davis');
$other = new Person('iAmine');


At a cursory glance besides the dollars C# classes are the same:

class Person
    // Field 
    public string name;

    // Constructor that takes no arguments. 
    public Person()
        name = "unknown";

    // Constructor that takes one argument. 
    public Person(string nm)
        name = nm;

    // Method 
    public void SetName(string newName)
        name = newName;
class TestPerson
    static void Main()
        // Call the constructor that has no parameters.
        Person person1 = new Person();

        person1.SetName("John Smith");

        // Call the constructor that has one parameter.
        Person person2 = new Person("Sarah Jones");

        // Keep the console window open in debug mode.
        Console.WriteLine("Press any key to exit.");

The differences between Microsoft’s C# and Sun’s Oracle’s Java are even smaller.


Microsoft’s TypeScript is yet another language to JavaScript compiler, this time from Anders Hejlsberg inventor of Java C#.

class Person {
    private name: string;
    private age: number;
    constructor(name: string, age: number) { = name;
        this.age = age;
    toString(): string {
        return + " (" + this.age + ")";


TypeScript code looks like C# and PHP.


TypeScript also looks a lot like ActionScript 3:

package com.example
    import flash.text.TextField;
    import flash.display.Sprite;
    public class Greeter extends Sprite
        public function Greeter()
            var txtHello:TextField = new TextField();
            txtHello.text = "Hello World";

Class declarations and type annotations in TypeScript and ActionScript look almost identical. ActionScript can be compiled to JavaScript or native code for iOS and Android using PlayScript.

Language wars

Looks like web developers using PHP, ASP.Net or Flash have quite a lot in common.

Random Walker

This week our automated tools uncovered a fatal exception before it reached the client. Nick and Anton, 2 of the full-time testers on our team have written a testing tool they call Random Walker that simulates interactions with the user interface as clicks and gestures. It has helped uncover numerous issues, particularly NullReferenceExceptions, more often than not emanating from third-party libraries. It typically finds issues that are not easily found by manual testing or our extensive suite of unit and integration tests. Up-time is very important to us and our large client base who interact with our software throughout the day. 

Stack Trace

System.InvalidOperationException: GridViewColumnCollection is read-only now.
 at System.Windows.Controls.GridViewColumnCollection.VerifyAccess()
 at System.Windows.Controls.GridViewColumnCollection.RemoveItem(Int32 index)


The exception is thrown after calling RemoveItem method of GridViewColumnCollection, although the MSDN documentation does not specify an exception is expected.


Using a disassembler we can see VerifyAccess will throw if the IsImmutable property is true:

private void VerifyAccess()
    if (this.IsImmutable)
        throw new InvalidOperationException(


The next question is when does this property get set to true. Using Telerik’s JustDecompile you can right click the property and select Find Usages, which shows its set from methods BlockWrite and UnblockWrite.

BlockWrite is called by the GridViewHeaderRowPresenter.StartHeaderDrag private method.

UnblockWrite is called by GridVIewHeaderRowPresenter.FinishHeaderDrag.

StartHeaderDrag is called from the MouseMove handler.

FinishHeadDrag is called from OnMouseLeftButtonUp, OnLostMouseCapture and OnColumnsPresenterKeyDown.


There appears to be an undocumented assumption that the columns can not be updated either during or on completion of a drag operation. However our front end lets you add or remove columns from a table via a separate menu, so it is possible for an update operation to come from outside the drag gesture.


One workaround is to pre-empt the call to VerifyAccess by checking the IsImmutable property as it is possible to invoke private methods via refection:

bool IsImmutable()
    var flags = BindingFlags.Instance || BindingFlags.NonPublic;
    var property = columns.GetType().GetProperty("IsImmutable");
    return (bool)property.GetValue(columns, new object[] {});


Closing Thoughts

The Random Walker UI testing tool has really helped flush out those hard to find issues, if up-time is important to your customers, you may want to consider using one. Bugs exist even in mature frameworks like WPF, and you may need to set aside some time to working around them. Encapsulation seems good in theory, but I’m thankful that we can disassemble the source of third-party libraries and dynamically invoke private members when necessary.