Development

Managing online development communities

Monday, June 15th, 2009 | Development | No Comments

A few friendly reminders to people shepherding development efforts:

  • Strike a cordial tone and do not tell people they do not understand the code.
    Doing this repeatedly to frequent contributors is even more silly.
  • Do not ignore contributions.
    It’s ok if you are busy, but indicate that by replying to the patch, do not ignore it completely.
  • If someone takes the time to go over your bug tracker and fix multiple issues, do not ignore the patches.
    See above.
  • If someone tells you that there are issues in your use of transactions, do consider it an option.
    Transactional safety is hard, it’s likely that details might have been overlooked.
  • Find a decent working process for reviewing contributions.
    Requiring contributors to bug you until you magnanimously take a look at the contributions gets very tiresome quickly and lessens the odds that said contributor will keep contributing.
  • Give constructive feedback.
    Stating ‘This sucks, but I don’t have time to explain right now.’ helps no-one but your own ego. A better approach, in case you really do not have the time, would be to write, ‘I have some concerns over the implementation that I would like to voice. I am, however, travelling for the remainder of the week and will try to reply early next week’.

That is all.

Covariance and design principles

Thursday, October 18th, 2007 | Development | No Comments

As promised in the last blog post, it is time to get down and dirty with technical facts. Or said in another way, it is time to look at: ‘Why C# let me down’ (you may imagine the blood dripping from the italicised letters). As the title may lead you to believe, the let-down has a lot to do with covariant types, but what are covariant types anyway? Why do they matter? And then how come C# does not have them?

The basic principles of object-oriented languages builds on what in type theory is known as subtyping relationships that are typically expressed σ <: τ, meaning that σ is a subtype of τ. Or expressed in a typical C# manner:

public class τ {}

public class σ : τ {}

So in other words, we have the property that σ inherits from τ, or that σ is a subtype of τ. It is typical of most object-oriented programs (sorry, most well-written object-oriented programs) to allow you to use the type σ in place of the type τ anywhere in the program and still have a correct program. This is what is typically called Liskov’s substitution principle, which can be formulated like this: x : τ ⊢ q(x) ∧ σ <: τ ⇒ y : σ ⊢ q(y). So that is fairly densely looking and what does it really mean? Basically it says: if q(x) is some property that holds on an object x of type τ and if σ is a subtype of τ then if y is an object of type σ then q(y) must also hold. Or in layman’s terms: it must be possible to use a child class instance everywhere a child’s class ancestor is expected, without changes to the program, maintaining correctness of the program. So that is probably a pretty good property to go looking for.

Now, before everything gets lost in theory, let us take a look at the actual problem in C#, using an illustrating example:

public abstract class RandomNumberGenerator {
  public abstract double NextValue();
}

public class DiceResultGenerator : RandomNumberGenerator {
  public DiceResultGenerator(int rolls, int sides) {
    rolls_ = rolls;
    sides_ = sides;
  }

  override public double NextValue() {
    ...
  }

  private int rolls_, sides_;
}

Okay, so this code is a sensible implementation of some random number generator and a dice roller… or is it? When was the last time you got floating point results from rolling a die? Let us fix that up right here and now by changing the double in the DiceResultGenerator to an int. This is a safe operation since int <: double (and because Liskov’s substitution principle otherwise applies here—every time you expect a double you can safely use an int in its place). Ignoring floating point representations and byte sizes this typically holds in most object-oriented languages since the integers are contained in the real numbers. So what happens if we compile the modified source code with the Mono C# compiler (the Microsoft one will give a comparable result)?

`DiceResultGenerator.NextValue()': return type must be `double' to match overridden member `RandomNumberGenerator.NextValue()'

Bummer, we have not got covariance in method return types. This means that whenever we use a DiceResultGenerator, we must get a double out of it, rather than a int, and we will subsequently have to cast it to an int. All this just because the DiceResultGenerator is part of a sensible inheritance hierarchy for different means to obtain random numbers and that most random numbers are floating point values. That is just plain depressing.

So this is exactly what a covariant return type is: when a child class wants to return a subtype of what the overridden function of the ancestor class returns. And it does not work in C#. Of course, it works in C++, but there are so many other things that annoy me with that language.

C# why did you let me down so?! Oh well, it must be time to find the next language I might actually like.

Edit: Astute readers found out that I had switched the subtype relation around in the definition of Liskov’s substitution principle. Sorry.

Tags: , , , ,

X-Chat 2 Plugins

Tuesday, November 29th, 2005 | Development | No Comments

X-Chat 2 for Windows had its binary download changed from a free download to a shareware download with a 30 day limit a while ago. This was considered by many as a really bad idea. People thought the idea so mind-bogglingly stupid that they created their own free alternate builds without a trial period. This post is not about the thing that makes a lot of people feel like feeding the X-Chat 2 for Windows maintainer to the Ravenous Bugblatter Beast of Traal. No, not at all. What this post is about, however, is writing plugins for this IRC client. No, that’s not what it’s about either, let me try again. What this post is about, is my mind-bogglingly useless plugin for this IRC client. Yes, that’s better.

The plugin I have created is for controlling Winamp from X-Chat 2. Normal plugins for X-Chat 2 are made in C, but I have made a plugin in C++. The source code will illustrate both how to integrate with X-Chat 2 and Winamp using C++.

The plugin will not auto-display what you’re listening to whenever a song in winamp changes, since I find that annoying. In fact this plugin will do nothing at all unless you ask it to. The plugin’s functionality is bound to the WIA command, so to see the help for this thing, just go /help wia. The rest should be fairly self-evident.

I have only tested it on the alternate build I’ve listed above. If it does not work on other builds then try to compile the source on your own. I will not help you with problems with the source, compiling it, your social problems or anything else even remotely related to my X-Chat 2 plugin for controlling Winamp. (You get to figure out how your social problems may or may not be related to that on your own). The plugin is released under the GPL and standard disclaimers are in effect and all that stuff that keeps kind people from sucking (sorry, suing) every last penny out of me. (Not that we have pennies here, but figuratively speaking).

I hope someone, somewhere, sometime, might have some use for this. I haven’t added it to the official plugin repository for a reason. Please, don’t post my plugin there.

Binary files (.zip) – 31.4 kB
Source files (.zip) – 26.8 kB

Tags: ,

WSE, DIME, certificates and large attachments

Sunday, October 16th, 2005 | Development | No Comments

Sometimes technology isn’t really transparent enough, even for us developers. When you do web development with IIS, WSE and ASP.NET you might consider it fairly straightforward to create a webservice that accepts file uploads. I thought so, so off I went coding. Everything went well, the files were being uploaded. Time to test this on production data: 400 Bad Request. Hmm.

Of course, prior to this I have already modified web.config to up the max request length like this:

<httpRuntime maxRequestLength="40000" />

So why is it refusing files with an error 400 as soon as they go beyond about 4096KB? Well, it’s obvious, WSE has a built in limit that you must change as well! (In case my sarcasm isn’t showing, it was there. Trust me.)

<microsoft.web.services2>
  <messaging>
    <maxRequestLength>1024</maxRequestLength>

  </messaging>
</microsoft.web.services2>

This example is taken directly from the WSE documentation for the maxRequestLength. Also, you must remember to add the configuration section extension definition for WSE as well – see the documentation link for how to do this.

Of course, the story doesn’t end here. That would be too easy, because the file upload still has a tendency to fail. Hmm. What if we try to sync the value between httpRuntime’s maxRequestLength and WSE2’s maxRequestLength? Bonus! So, knowing that these two have to be identical for everything to go well it seems a bit… ridiculous to have to require the WSE2 field instead of WSE2 just using the httpRuntime value for the maximum request length. I’m sure there’s a brilliant reason for not doing this, however, that someone at Microsoft may know, but one could at least have it be equal to httpRuntime’s maxRequestLength, no? pretty please? Ah well. I’m sure I’m not the last to run into this problem.

So, now we have taken care of large attachments. Let’s add a bit of security so we can safely validate the sender of these large attachments. Stage left enter X.509 and SSL certificates. Stage right enter more troubles, a lot more troubles. So let’s look at a fresh start of IIS and the client, let’s upload a big file, let’s say 20 MB: 413: Request Entity too Large. I will have to be frank, this surprised me. How can the request be too large on HTTPS with client certificates when it isn’t too large on HTTPS without client certificates or on HTTP?

My science background teaches me to experiment in this case, so let’s try it first with a small attachment, say 4 KB, and then let’s try it with a big attachment, say 20 MB: 200 OK. Hmm. Not only does this seem to indicate a bug in IIS6 (which was the IIS I was working against), but it seems to indicate that there is some non-trivial state sharing going on between disparate connects from the same client. Unfortunately I haven’t had time to work more on this problem, but if I ever get around to fixing it I’ll make an update about it. For now I have just created a system that takes a temporary “session” variable that is fetched using a certificate call and then the file is uploading using this without certificate. Seems to work.

Gotta love obvious, transparent technology.

Tags:

C#, VB and LINQ

Friday, September 30th, 2005 | Development | No Comments

I went to a colloquium on LINQ (I guess this link might die in the future when the future is no longer the future, so to speak) presented by Erik Meijer who is a technical lead in the WebData group (whatever they do). Meijer is a very charismatic speaker and it was a very good presentation he did (although Virtual PC on his laptop couldn’t entirely keep up). For the uninitiated LINQ stands for Language INtegrated Query and it brings set relational functionality to .NET. VB9 and C#3 will have syntactic sugar for it, other languages can consume it using the assemblies.

LINQ correspond to Haskell’s monad comprehensions, in case you know what those are, and I think it will be interesting to see how people put it to use, but I could fear that it will create a tendency to put even more data-layer specific code into the business aspects of application. The added expressitivity, however, seems like a great thing and I look forward to play with it.

Meijer also presented a couple of the new things coming in VB9, among these is late-late binding, which allows you to try to access fields on a type Object regardless of whether you know they exist at compile-time or not, so in some sense VB9 is now a complete bastardisation between statically and dynamically typed languages and you get to be able to do some truly nasty things:

  Dim z As Object = {Name := "Test", ID := 20}
  Console.WriteLine(z.(Console.ReadLine()))

This allows you to specify the field in the anonymous struct to access at runtime, no more static typing, there be monsters here! What does this mean for Visual Basic programmers? I would guess that the group of programmers that are currently programming Visual Basic aren’t exactly, in general, those who know what type erasure, type inference and monad comprehensions mean. I wonder whether Microsoft may be letting their developer base walk the plank in some sense, but only time can tell.

Erik Meijer has been teaching as an assistant professor at the University of Utrecht prior to being with Microsoft and one of the most refreshing things in the presentation was to see a theoretical person using all his theory and knowledge of paradigms, semantics and whatnot to improve (I hope) production environments. All in all a great presentation, I’m still spaced-out about being able to access a lot of my functional programming things in C#.

Finally the fun anecdote Meijer gave during his presentation: Originally LINQ was called LIQ, but marketing changed it to LINQ as Language Integrated Query Object Relations would’ve become LIQOR otherwise. Can’t have that, nope.

Tags: , ,

On CRC Cards and Design

Saturday, May 14th, 2005 | Development | No Comments

Sometimes you just wish you had paid a bit more attention back then in the first few semesters of studying Computer Science, but oh no, you were too busy/young conquering the world. As such it has been that I have been overlooking The CRC Card Book for nearly five years now, where it has been standing vigilantly on my bookcase. Since I have gotten more interested in teaching object-oriented methodologies over the past year and some, partially due to my internship, I figured it was on high time to take it down from its place on the shelf and read through it. I was not disappointed.

The book takes you through the object-oriented terms, strategies for evolving good designs, bringing the users into the process, and guiding everything along nicely by role-playing use cases, etc. While the ideas seem sound, psychologically speaking, I cannot help but feel that the described test cases work out just a bit too well. However, I am hoping to be pleasantly surprised and see that it can indeed work in a setting where people’s understanding of object-oriented design is rather rudimentary.

Tags: ,

Zooming the editor

Monday, March 7th, 2005 | Development, Personal | No Comments

A while back Sara Ford offered up “I love Visual Studio Core” t-shirts for people who wanted to contribute a bit of code for the Visual Studio 2005 PowerToys. Not passing up the chance for a t-shirt, I contributed code to a zoom control. Now the add-in is stored on gotdotnet, so good luck finding a time when it isn’t crashed in some way.

For the interested parties, there’s a photo of the shirt on my floor, here…

Shirt

Tags: ,

Atomic Cellular Dysfunction

Thursday, February 17th, 2005 | Development, Personal | No Comments

It isn’t that my organism is self-destructing (much) that I’ve picked this rather funky topic for today’s post, nay, it is far more sinister and dark – it is the topic of a contest that I participated in, together with Noah Adler last month, a contest that was about creating a game in 48 hours to the theme: Atomic Cellular Dysfunction.

We managed to create, within the 48 hours, a lovely game in style with the games of the 80s that we have both grown up on and loved, so without further ado, we bring Atomic Cellular Dysfunction to the world. We hope you will enjoy it as much as we enjoyed PacMan and the other great games of our time.

Tags:

Zoom zoom zoom

Tuesday, February 15th, 2005 | Development | No Comments

I was featured on Sara Ford’s blog and the VS 2005 News blog for my involvement with writing the VS Editor Zoom Add-In, which is an add-in bringing Word’s zoom control to Visual Studio .NET 2003 and Visual Studio 2005 December CTP so far.

I hope some of you may find a need for some zooming.

Tags: ,

Enterprise Architecture

Monday, February 14th, 2005 | Development | No Comments

I just finished reading Fowler’s Patterns of Enterprise Application Architecture, the last Christmas present I still had to finish. I can’t seem to help feeling that it misses its audience in part with its narratives, depicting different aspects of enterprise programming, and even then all of a sudden go back to text-book descriptions of atomicity in transaction handling for threading. Very odd.

As usual, Fowler notes that he just records the patterns he has witnessed and everyone experienced in enterprise architecture will know these already, and it is rightfully so, so no mark against him there. Now, the Java crowd seems rather enamoured by the OR-mappings and being from that crowd, Fowler recounts those patterns. I am rather ambivalent on its merit, both the book’s and OR-mappings’, so I think I will settle with suggesting this book to newcomers to enterprise development, as a quick introduction to some of the more recurring patterns in the field.

Tags: ,