Differences Between Test Runners; Mouse, Monitors & Keyboard Shortcuts

by Kofi Sarfo 22. October 2009 06:20

Differences

It was more than a little odd to see tests pass using the ReSharper Test Runner but fail when using either NUnit or the as yet mystery default option (whichever is used when Test With > Debugger is selected from the context menu).

Test with DebuggerReason being that ReSharper is kind enough to run the tests in the order they appear whilst the others do so in alphabetic order. Dependencies between tests become apparent. Slaps to the forehead are delivered. We resolve to steer clear of using statics for unit testing.

Mouse

With only one monitor at work - everyone has just the one monitor so we're not too keen on standing out for being flash by having two monitors! - it would be handy having test results appear in the status bar using an ALT-T shortcut and TestDriven.NET. However, licensing! So it's tabbed Unit Test Sessions and CTRL-TAB until we're in the promise land.

Keyboard Shortcuts

Also, it turns out the the advertisement for going mouseless is true. Keeping the hands on the keyboard does indeed speed up coding. The next problem then was trying to access the Debug Tooltips (available ordinarily by hovering the mouse over variables). The solution is AutoHotkey and the script is courtesy of Rob Henry.

Bloomberg 1970s

by Kofi Sarfo 15. October 2009 19:51

Bloomberg connectivity is a riot. We submit (by FTP) a text file with an expected format using carriage return and line feed to separate data entity requests.

From C# this means shelling out to a batch file (remember DOS) which executes some Java code responsible for handling request/response. If the request is valid then one minute later a zip file is returned that contains a text file. We parse and we have a database ready data file. If the request is badly formed, however, then an error file is created on the remote FTP directory but that is never returned!

Five years ago someone asked on WILMOTT (serving the Quantitative Finance Community) how to connect a Java application with Bloomberg to send and receive data. Dominic Connor was kind enough to reply.

At another time, at another place we used the DLLs on the Bloomberg terminal to return the data we needed. It was fast, efficient, predictable and illegal. Good times.

You may be here looking for something on bbdlftp or BBDL FTP. Good luck.

Tags:

Nostalgia

I have a need, a need for a quote from an iconic 80's film

by Kofi Sarfo 7. October 2009 00:52

It's been almost one week since we started doing this daily code Kata: Roy Osherove's TDD Kata 1 - String Calculator. Thirty minutes every day in October so far. Six days. Three hours. Writing the same functionality over and over. What happens is that, naturally, each time we get a little closer to the end (we've not yet completed it in thirty minutes) and we optimise by anticipating functional requirements and code to allow for simple changes ahead. We'll decide how much of this is cheating once we're actually done a few times within thirty minutes before moving onto the next Kata.

We're using just the one code snippet, TDDtestmethod, which generates a test method. We abandoned the calculator variable name, opting for c.Add instead.

Is there a prize for the longest [Test] case method name?

Calculator_ MultipleDelimeterVaryingLengthSpecifiedDelimitedMultipleStringDecimalValues_ ShouldReturnSummedValues()

Using underscores would only make matters worse. And when we looked at some of our tests recently we discovered that we were unit testing parts of the framework (guess we're still not sure about Entity Framework) and using unit tests for spikes too. The words "Gone Too Far" appeared suddenly.

Tags: ,

Dojo

On Transparency

by Kofi Sarfo 1. October 2009 18:39

Today, a courier cyclist arrived bearing the gift of a new contract for new employment. If everything goes as expected we'll be working in the City within two weeks.

It's perhaps better not to mention the employer by name but they're a solutions provider working within an interesting area of finance and our role's likely to involve helping to ensure the reliability of systems processing terrabytes of data with issues of cleanliness and performance being most important. We're thinking optimised data querying, concurrency (scale) and transformation/calculation.

Without much recent UI experience all the cool Winforms & Web developer roles seemed out of reach so this is where our spare time needs to be invested over the next couple of years whilst the day job is all about the data, touching possibly on F# and elements of grid computing and much more of the modelling languages: UML & XML.

In terms of development approach the experience from the last consultancy role at Man Investments should prove invaluable in terms of transferring agile methodology and process where appropriate but because this is a smaller company, enterprise systems integration complexity ought not to present the same kind of challenges. I'm hoping for a more contained, bounded, intra-application kinda complexity. Those woods and trees managed to get quite blurred in that last assignment.

The new mission is to help provide Market Transparency. After five years in Hedge Funds it seems fitting.

I should add that Man Investments was a fantastic place to work.

Tags:

Interviewing

The Poor Man's XLink-Like Thing

by Kofi Sarfo 23. September 2009 01:18

The following StackOverflow post is interesting not so much because of the text but how it's rendered.

Loading Stack Overflow post...

We begin with a <div> tag which contains an expected id attribute format and using a jQuery regular expression we're able to match all div elements with an "id" attribute beginning "RSSContent".


<div id="Container">
<div id="RSSBlock">
<div id="RSSContent200909222115"
runat="server"
title="http://stackoverflow.com/feeds/question/477962" />
</div>
</div>

The "title" attribute for each element matched is used in an HTTP post of content-type application/json to a web service which acts as a proxy to overcome cross-scripting JavaScript constraints. This returns the post above which I found useful recently.

It's not an elegant solution. I've hacked the div element, using the "title" attribute to hold the URL and the directory structure isn't great either. The web service creates a user control which appears to work only in the root directory and the web application project requires a reference to an identical control in another project. The things we do for code compilation!

The end result is that rather than cut & paste, which would have been far easier we're using using an external resource to supply text so that if the RSS feed item was to change, for example, then we'd still display the most current version.

An XLink implementation, this is not. It's just an example of how I thought the web might work sometime soon after 2001... What we're missing here, conceptually at least, is meta to describe the relationship between this post and the one referenced. Well, in this case the meta is only human-readable and quite incomplete.

Tags: ,

JSON | Toys

Xml Namespaces I've Loved and the Nature of RSS

by Kofi Sarfo 20. September 2009 17:02

Yesterday, during yet another interview, we didn't deliver quite  the finest explanation of what an XML Namespace is. Today, we're using them to parse a Stack Overflow feed so clearly we understand them, however, if part of the question's purpose is to assess our ability to express this simple idea simply then shitehawks! #fail

Take this feed, for example, which is the RSS for a useful post on Volatile vs. Interlocked vs. lock. In order to to be able to use XPath with XDocument to retrieve the question we rely on XmlNamespaceManager.

    var xDoc = XDocument.Load("http://stackoverflow.com/feeds/question/154551");

    var xmlNamespaceManager = new XmlNamespaceManager(new NameTable());
        xmlNamespaceManager.AddNamespace("atom", "http://www.w3.org/2005/Atom");

    var postedQuestion 
        = xDoc.XPathSelectElement("/atom:feed/atom:entry/atom:summary", xmlNamespaceManager);

This is another example of Stack Overflow brilliance. The feeds are in chronological order so that we can guarantee that the first item (or entry) is the original post. Following the Volatile trail leads to a Joe Duffy post on Volatile Reads and Writes, and Timeliness. For example, he writes the C# documentation for volatile is highly misleading with reference to the following MSDN documentation:

The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock statement to serialize access. Using the volatile modifier ensures that one thread retrieves the most up-to-date value written by another thread.

Unfortunately, I can't find this specific RSS item within the Technology feed and the same is true for the RSS feed for this blog. Although it's possible to score a reference to the item if it appears within the list of entries as they each have a unique ID, should the category contain too many entries then the older posts don't show up. Soon I'll show why this might matter but I digress.

The quoted paragraph above came as some surprise and a few hours reading suggests that:
  1. This stuff is hard!
  2. It would take *years* at the exclusion of a whole lotta stuff to have a legitimate claim to deep understanding of the intricacies of threading in .NET
  3. A solid handle on this C# Threading series of posts might just be enough (for now).
The real trick, however, might be recall during interview. There's definitely a theme here.

Tags:

C#

The Dojo Prophecy

by Kofi Sarfo 19. September 2009 07:20

Bouncing back and forth between System.Threading and XP, we spot something from Matt Wynne reminiscent of Thursday's Dojo:

Rod has just joined a new team who are using UNIX text editors to do their development in Perl. Rod is used to using the Eclipse IDE and has never really used these text editors before so he feels awkward and clumsy when he gets the keyboard. This is compounded by the fact that his team are using a mixture of editors and operating systems, with some people staunch EMACS users, others using VIM and yet more using Textmate on the Mac.
Personas for Debugging Pair Programming Session

Tags:

Dojo

Picking Locks

by Kofi Sarfo 18. September 2009 18:35

One fact I forget with consistent regularity is that locks in C# and .NET for that matter are implemented using the System.Threading.Monitor class.

static object moveCountLock = new Object(); private int moveCount; private void IncrementMoveCount() { Monitor.Enter(moveCountLock); moveCount++; Monitor.Exit(moveCountLock); }

And if we were to place the Monitor.Exit in a Finally part of the Try/Catch then effectively it becomes the following:

private void IncrementMoveCount() { lock (moveCountLock) { moveCount++; } }

To put this all in some context, the code above is designed to address race conditions though the MSDN article on Concurrency from which I take this summary elaborates on locks. And whilst we're discussing locks it's worth considering the volatile keyword.

For non-volatile fields, optimization techniques that reorder instructions can lead to unexpected and unpredictable results in multi-threaded programs that access fields without synchronization such as that provided by the lock-statement.

Two things worth pointing out here. It turns out the famous Double-Check Locking flaw previously requiring the volatile keyword no longer needs one. At least not if you're using C# but might as well leave it in for Mono and friends, suggests Phil Haack in: Double Check Locking and Other Premature Optimizations Can Shoot You In The Foot.

A few hours worth of reading ahead I think...

Tags:

C#

Bookmarking Coding Dojo & Code Kata Resources

by Kofi Sarfo 18. September 2009 07:50

Python Coding Dojo

by Kofi Sarfo 17. September 2009 22:34

We've been on a mission since last week to get exposure to the test-driven as opposed to the test-sometime so tonight we find ourselves at the offices of Fry-IT in Southwark, London watching at least two Python gurus doing Code Dojo. It's reassuring to see recognised developers halted by unfamiliar editors and settings on an operating system few here have used regularly, no matter how pretty Mac OS might be.

We witnessed a Randori Kata:

A challenge is set and solved by pair programming (driver and co-pilot). Each pair has a small amount of time to advance the solution using TDD. When the time is up the driver goes back to the audience, the co-pilot becomes driver and one of the audience step up to be co-pilot.

Folks took it in turn driving/co-politing to create a social network graph using Graphviz based on Twitter friend/follower data. For someone who'd seen maybe five lines of Python (and ignored four of them) prior to this evening, this was a nice introduction to the language as things progressed at a nice, gentle pace. Whilst getting up to speed one helpful guy pointed out his Interactive Python Tutorial written in Silverlight. Nice.

It didn't take too long to see out why the language has become so popular. Take Fibonacci:

def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b

Compared to the C# 3.0 implementation it's utterly readable

Func fib = null; fib = n => n > 1 ? fib(n - 1) + fib(n - 2) : n;

The Python version fares even better than the C# 2.0 version

static int a = 0; static int b = 1; public static int DoFib(int num) { int temp_value; if (num < 2) { a = 0; b = 1; } else { DoFib(num - 1); temp_value = b; b = a + b; a = temp_value; } return a; }

Pretty good for a first code dojo; I took along a proper Python Developer to decipher some of the odd-looking, intellisense-free text appearing onto the projected screen. The next Python Coding Dojo is on in October and by then we may even have written something in Python. Baby Steps.

Tags: ,

Dojo | Talks

Kofi Sarfo modified theme by Mads Kristensen



Content by WIMIRO Technology is licensed under a Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License.

Creative Commons License

Powered by BlogEngine.NET 1.5.0.7

About Me

Director, Wimiro Technology
London, United Kingdom

Writes in third person and first person plural; currently commutes to Moorgate.

Kiva Loans

  • Kamala Hasanova

    Kamala Hasanova

    Cattle

    Requested loan: $1250

    Amount raised: $0

    Imishli, Azerbaijan

    To purchase cattle and six sheep.

    Loan Now »

  • Nizami Shirinov

    Nizami Shirinov

    Cattle

    Requested loan: $1125

    Amount raised: $0

    Imishli, Azerbaijan

    To purchase one milking cow and one calf.

    Loan Now »

  • Lhagva Dulam

    Lhagva Dulam

    Sewing

    Requested loan: $1450

    Amount raised: $0

    Hentiy,, Mongolia

    To purchase fabrics and materials.

    Loan Now »

 To see more entrepreneurs »

Kiva Loans