The best of software technology presentations

December 10th, 2009

I watch a whole lot of presentations on Youtube, Vimeo and InfoQ. Here are some latest picks of the bunch:

Eric Ries – The Lean Startup @ Oredev

Really useful advise on startups, be it a new product, a new business endeavor or a whole new company altogether.

Giles Bowket – Archaeopteryx MIDI generator @ Rubyfringe

I just love Giles’ delivery on this one. He’s presenting a MIDI generator software he’s been working on and throws some cold water on the industry in the process. An absolute classic.

Steve Souders – Even Faster Websites @ Google I/O

Invaluable tips on performance optimizing web sites, presented by the maker of YSlow.

Brian Fitzpatrick & Ben Collins-Sussman – The Myth Of The Genius Programmer

A talk about confidence, communication and facing failure. Among other things. Nothing really revolutionary here, but should be a good reality-check for many. I know it was for me.

That’s it for now.

bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Industry and career, Technology

KLM WTF

November 3rd, 2009

I was trying to check into my flight on KLM’s web site. I navigated to the check in form, entered my booking number and was greeted with this. WTF?

bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Uncategorized

Ninject & WCF

October 5th, 2009

Ninject relies on an HttpModule when instantiating the Kernel with OnePerRequestBehavior. WCF hosting infrastructure intercepts requests when the PostAuthenticateRequest is raised and doesn’t return processing to the ASP.NET HTTP pipeline. Ninject’s OnePerRequestModule only registers an event handler on the EndRequest event and thus isn’t ran on requests to a WCF service.

A quick fix for this is to enable AspNetCompatibilityMode on the WCF hosting infrastructure. In your web.config, add the following tag under your <system.serviceModel> declaration:

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

You also have to decorate your .svc class with the following attribute:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

I don’t know if this is an ideal solution however, and if it has any negative effects on performance etc. More elegant solutions seem to be available. More information on AspNetCompatibilityMode is available on MSDN.

bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Technology ,

Introducing Project: Moo

June 27th, 2009

Why isn’t the iterator MoveNext()ing?

Jouni Heikniemi

The thread was blocked for a while. Here we go again.

Domain: Digital DJ’ing

One of my recreational pastimes includes DJ’ing. I started out the old-fashioned way, playing round black slabs of vinyl, and did so for quite a few years. Eventually the great reform of the music biz caught up and I, somewhat reluctantly, went digital. I still use vinyl records for controlling the digital tracks I play out at gigs.

The setup I use is Native Instruments’ rather nice product called Traktor Scratch. It consists of an audio interface that gets plugged between the mixer and the turntables and a software that plays the actual digital audio files. The idea is that you place a special vinyl record with a time signature track recorded on it on the turntable, the time signature then gets played into the software via the audio interface, and the software then proceeds to play out tracks matching the speed and location of the vinyl. In effect it’s basically like having MP3 files on your vinyls.

The advent of these DVS (Digital Vinyl System) packages has – for me, at least – changed the dynamics of performing somewhat. In the yesteryear, a considerable amount of time would be wasted browsing through the crate, looking for that specific record. A search field in the DVS software’s library GUI has replaced the crate-digging, making it really easy to find specific tracks, but harder to go by intuition. That is a paradigm shift that I – after almost 2 years of gigging with a DVS system – haven’t gotten used to. This, I believe, is an issue that the DVS vendors should try to address.

Another challenge is keeping your MP3 files organized. If you only use your laptop for DJ’ing, it’s pretty easy to just shove your files into a directory and let your DVS software take care of cataloging them. I – like many others – do use my laptop for other stuff as well: like listening to podcasts and music that I don’t incorporate into my DJ sets. A DVS software isn’t actually a user-friendly way to listen to music casually and manage podcasts.

This calls for a gentle balance of using a DVS software for the DJ stuff and, say, iTunes for the other stuff. That’s all fine and good in theory, but when your libraries start to overlap, it becomes a bitch. And they will. Traktor Scratch has a rudimentary support for iTunes library integration, but in effect it always ends up bloating your DVS library with the latest Stack Overflow podcasts and Lamb Of God albums.

Then there’s the problem of dealing with considerable masses of individual MP3 tracks: applying genres, classifying, creating playlists, general cataloging biz. The stuff you do to battle the loss of intuition in selection. To date, I haven’t seen an MP3 player that makes it easy to apply a genre to 10 tracks and create a playlist of 15.

Enter Project: Moo

The idea of a media library / MP3 player for this distinct niche has been bouncing around in my thinkbox for some time now, but I finally got XCode fired up and started hacking at it this week. My original thought was to go at it with the approximate technology palette of RubyCocoa and CoreData, but after some 4 days of programming I’m starting to arrive at the conclusion that learning your ways around new technologies via a Objective-C bridge is a bit of a pain-in-the-poopshoot. So I think I’ll be rewriting the stuff I’ve got together so far into Objective-C. Should be interesting.

The approximate feature outline of the first-ish release should be something along the lines of:

  • Playback of MP3, WAV, AIFF and FLAC if it isn’t a complete bitch to implement
  • Minimal user interface relying heavily on the keyboard, for fast bulk editing
  • Applying arbitrary classifications for tracks: pretty much an extension to genres. A track can belong to several classifications but only one genre.
  • Playlists
  • The ability to create symlinked pools of tracks, classifications and playlists. The idea is that you can keep your DVS library pretty much clear and load up a directory of symlinks that you control with MOO
  • Podcast subscriptions
  • Insane abundance of doesn’t-cost-a-penny-but-do-donate-if-you-don’t-want-me-to-go-thirsty

Further iterations might or might not include:

  • Scriptability. Might even be pretty early in the roadmap, given the head-start the Ruby-Objective-C bridge gives.
  • Visualizations. But then again who gives a fuck. Would be a nice exercise for the brain-banana to implement, though.
  • WPF port

This, of course, will probably take some time, given that I don’t know KLONK about Cocoa. Stay tuned, however. This might actually evolve into something, considering the surprising vein of inspiration I seem to have struck.

Feel free – all 3 of you – to suggest features. If your ideas are relevant to the domain I might even consider implementing them. Remember, though, that this is a personal technological venture first and a software product second. But if this thing does catch wind, the focus could do with some adjusting.

I’ll try to blog during the process. Might even publish some source code shiznit if I think I’ve actually managed to stumble upon some release-worthy code. The basic idea would probably hover around Cocoa development from the perspective of an experienced Microsoft developer.

Why is it called Moo, then? Fuck if I know. Cows say Moo. Cows are stupid.

bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Technology , , ,

Semantic domain modeling

February 10th, 2009

Coding, after all, is just writing.

Jeff Atwood

Yup. Jeff covers some essential aspects of the curious relationship between writing and coding in his post, focusing on the perspective of style and readability. I’ll now give a shot on extending on that topic. I’ve been kicking around the subject of domain modeling in my post drafts bin for quite a while, not knowing how to present it. Today it hit me during a sprint review at a client. There is nothing revolutionary here. It’s all basic domain modeling and design patterns, but viewed from a different angle.

Numerous are the times I have come across inconsistencies in domain models due to misunderstandings in the development process from the actual domain to object model. I’m sure you have too, and this is nothing new under the sun, and to some degree somewhat unavoidable. Perhaps you’ve also seen objects used for something they weren’t meant and designed for. This could be due to architectural shortcomings, laziness or just plain ignorance.

As a harsh example, I’ll describe a case of architectural shortcomings that forced me to do an ugly hack and thus leverage a wrong object for the job at hand. The GUI components of the application featured a parameter-generated form – dubiously titled ViewForm -  for performing complex database queries to ultimately retrieve an entity to open into another form for modification.

First of all, naming the form ViewForm is just a cracker-jack job at crafting an ubiquitous language. It’s a form that views stuff. You must be shitting me. How about SearchForm? After all, it’s a form that searches stuff. Infrastructural domain objects should be named with equal care as the ones in the business end that have taken years and years to refine into concise,  yet semantically clean terms. Ultimately the distilled purpose of the ViewForm component is to search stuff, so I’ll assume from now on that this naming quirk hadn’t been there.

The hack in question? I was asked to implement a search form that queried two separate tables – import and export shipments – and opened a different form depending on the type of consignment the user double-clicked on. I ended up creating a dummy form with absolutely no visual components on it, and some code in the Form_Load (or such, luckily can’t remember a thing of the VB6 API’s) event handler that figured out which of the two consignments it was, opened the corresponding form and closed the dummy one.

The said form performed nicely enough in the job of querying, and being configurable and all that. The problem, however, presented itself when a series of domain modeling mistakes met, reaching a critical mass of code smell. Following are the essential shortcomings that led me to produce probably the ugliest hack I’ve ever had the balls to ship:

  1. We’re talking about ERP-style software here, and thus object-oriented programming should be a given. No objects here, other than infrastructural ones, courtesy of VB6 (Form, Control etc). This results in aforementioned search form querying for database rows instead of entities. So no strong typing to be relied on. That also means that refactoring the query form configuration model would’ve been a tedious exercise of implement-and-wait-for-the-bug-reports.
  2. When the data schema is modeled merely as database tables and a bunch of functions scattered across random forms all over the place, the domain model easily scatters into a bit of a disorganized mush. In this case, the business requirements dictated that the system should handle import and export shipments, thus the developer creates separate tables for them without stopping for a minute to ponder the semantics of the two. A shipment is a shipment, regardless of its direction, I dare to assert.
  3. The configuration data schema for the query form was modeled so that there was a query form definition and it had a bunch of associated column definitions. The gotcha was that the query form definition held the name of the form that would be opened when a user double-clicked a row in the results grid. The semantics of a query form per se come into question here – is query form a query form or a query-and-open-another-form form – but mostly in the sense of separation of concern.

Though all of the aforementioned architectural turds play an important role, the third one is the most essential one in this particular case. The coding-as-writing analogy plays out here in the sense that having a semantically clean ubiquitous language paves the way for clean and pragmatic separation of concern. If the domain model defines a search form, you implement a search form that knows about searching for stuff, and that maybe something needs to be done with the stuff that it finds: something, but not what exactly.

Rather than referring to an individual form to open, the search definition should’ve pointed to a strategy object that would’ve done whatever it wanted with the row of information: figure out a form to open or perhaps perform some other processing on the record. Now I had to emulate that behavior using a Form object to do something it’s not designed nor meant for.

Moving on to unfolding screwup number two. I once tried fishing out a reason for the crowbar-separation of the two shipment directions and got something along the lines of “well it’s because they are a totally different business”. Well humm righty-o, but isn’t a shipment still a bunch of goods that is going from one place to another, results in costs to an array of involved parties and is dictated by a set of legislation, contracts and whatnot?

An imported shipment might hold some information that an exported one doesn’t and vice versa, but object-oriented programming provides inheritance and relational databases provides relationships for just that. Eventually both of the shipment types still need to be treated as equals, just like what happened here. Another highly probable case would be a statistical report on import-to-export ratios.

The key point I’m trying to make here, is that, if the ubiquitous language has been crafted carefully, evaluating semantics provides a logical and robust back bone for designing the object model. Now that I think of it, I can’t see another way to really model a domain. Yet every day I witness failures – albeit smallers ones – in modeling that would’ve been solved by really grinding the terms used to describe the objects.

When an ubiquitous language starts to take shape, go through the terms described and really chew them fine. If the term isn’t concise or unambiguous enough, finetune it until it is. Then use that information to form a pragmatic object model that separates concerns logically.

bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Technology , , , ,

How to nest NHibernate mapping files in Visual Studio projects

February 3rd, 2009

Nesting files in Visual Studio projects is as simple as (pun intended) opening your project file into a text editor, finding your reference to a project file and adding <DependentUpon>Class.cs</DependentUpon> within the element.

However, there’s a catch. Nesting the files causes the file names to be overwritten. In this case, the .hbm.xml suffix gets dropped. That effectively prevents Configuration.AddAssembly() from finding the mapping information. A way around this pitfall is defining the dependency as follows:

<EmbeddedResource include="ServiceRequest.hbm.xml">
<DependentUpon>ServiceRequest.cs</DependentUpon>
<LogicalName>ServiceRequest.hbm.xml</LogicalName>
</EmbeddedResource>

Thanks go to Sami for cracking this nut with me.

bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Technology , ,

How to lock your Mac OS X

February 3rd, 2009
  1. Finder -> Applications -> Utilities -> Keychain access
  2. Keychain access (menu item) -> Preferences
  3. Check “Show Status in Menu Bar”
  4. To lock your workstation, click on the lock icon in your Menu Bar and click “Lock Screen”

Just thought a no-nonsense reminder about this is in order.

bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Technology , , , ,

Chinese New Year 2009 in Helsinki

January 26th, 2009

The Chinese New Year was celebrated in Helsinki for the 3rd time on 25th January 2009. The event featured spectacular wushu, puppetry, chinese opera and dance performances. I froze my ass off standing in the slush photographing some of the performances. Enjoy.

bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Photography , ,

Log4net vs. Enterprise Library Logging Application Block

January 23rd, 2009

I was contemplating a logging strategy in the context of a customer project and I bumped into this slightly dated performance comparison between log4net and Microsoft Patterns & Practices – Enterprise Library 3.1 Logging Application Block (which I’ll refer to as LAB from now on). Considering the fact that our logging library of choice is LAB, I started wondering what the situation is today.

I wrote (heh) an empty trace listener for LAB and an empty appender for log4net and ran a couple of unit tests. While not nearly as dramatic as Loren Halvorson’s findings 4 years ago, the results weren’t exactly flattering from LAB’s perspective.

The unit tests wrote 100000 info level – not that it matters, after all we’re using empty appenders – log entries and timed the whole deal. Log4net’s effort took a respectable 153ms, while LAB’s time was a significantly longer 1396ms. I also tried actually writing the entries out, using FlatFileTraceListener and FileAppender on LAB and log4net respectively. The results: log4net 1450ms – LAB 4243ms. Not as dramatic, but relevant nevertheless.

Oh, and by the way, I’m not handing out a table of the dubiously conducted performance test results, because I’m mean and I want you guys to read my posts.

Going beyond performance, setting up LAB is – to put it gently – laborious. Microsoft’s documentation doesn’t offer configuration examples in their native xml form. Rather, they “encourage” you to use a configuration tool that is shipped with Enterprise Library. That sucks. I had to download and install Enterprise Library to use a tool to edit App.config, instead of just copying the DLL from a project I already had and modifying a copypasted configuration to suit my needs. I hate clicking around to produce stuff that’s essentially lines of code in my Visual Studio solution.

Then there’s the behemoth of an API that LAB sports. Constructing LogEntry objects, then asking whether it should be logged and then writing them out to the logger isn’t actually succinct. Surely you can encapsulate this behavior in your own helper methods, but I can hardly see the point in rewriting the API. Logging code should be really succinct, and by default log4net’s API provides ways to do just that.

log4net 1 – MS Logging Application Block 0

ps. Do note that Enterprise Library 3.1 is already outdated so I don’t know if these conclusions apply to Enterprise Library 4.1.

bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Technology , , , , ,

String comparisons in C#

January 19th, 2009

This is my first in the line of note-to-self posts. I don’t know if there will be more. I sure hope there will, ’cause that’d make me remember all the trivia I pick up while scavenging the intar webs.

Anyhow.

I bumped into this semi-useful bit of information while browsing thru stackoverflow. How often do you normalize your strings for case-insensitive comparisons? Quite often, I presume. Well me too.

Turns out, that strings shouldn’t be normalized by calling ToLower() on both sides of the == operator. According to CLR via C#, the ToUpperInvariant() method should be used instead of the ToLowerInvariant(), as stated in chapter 11 of the book:

If you want to change the case of a string’s characters before performing an ordinal comparison, you should use String’s ToUpperInvariant or ToLowerInvariant method. When normalizing strings, it is highly recommended that you use ToUpperInvariant instead of ToLowerInvariant because Microsoft has optimized the code for performing uppercase comparisons. In fact, the FCL normalizes strings to uppercase prior to performing case-insensitive comparisons.

Whatever that means. I’d like to think that Microsoft has optimized the code for everything.

But there’s a catch. Had I been a C programmer, I would’ve probably thought of this myself, but luckily the comments on stackoverflow alerted me to a valuable realisation:

Don’t do case-insensitive string comparisons with the == operator.

The thing is, ToLower() and ToUpper() methods both have the same pitfall: due to the string type’s immutability, they create another copy of the string into memory.

Use String.Equals(String, String, StringComparison)

In addition to being resource-effective, using  the static Equals method saves you the trouble of checking for null values. Like this, per favore:

string foo = "Foo";
string bar = "foo";
if (String.Equals(foo, bar, StringComparison.OrdinalIgnoreCase))
{
     // ...
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Technology , , , ,