Archive

Archive for the ‘Technology’ Category

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

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 , , , ,

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 , , , ,

The toolbox

December 23rd, 2008

I’m not too big on bloating my Visual Studio with addons and whatnot, but there are a few tweaks here and there. My Visual Studio color scheme is a slightly tweaked version of the Desert Nights scheme by Thomas Restrepo. You can grab it for Visual Studio 2008 here.

I also use the awesome Sonic File Finder addon. It allows you to search for files in your solutions. Programming can be a frantic excercise in jumping between numerous code files and the solution explorer is a really poor way to do it. Most of the time you know what file you’re going for, so just hitting ctrl+, and typing a part of the file name saves you a bunch of time and sanity.

I also used to use the ApexSQL Edit for its superior performance and intellisense feature but it kinda got rendered obsolete after the release of Sql Server 2008 with its built-in intellisense. ApexSQL Diff, however, is a great tool to have in your belt. It does what you’d expect: compares database schemas and merges them. It performs surprisingly complicated merges without breaking a sweat. Both of the aforementioned applications by ApexSQL are of extremely high quality, they perform well and are stable as the negation of something not very stable. Highly recommended.

bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Technology , , ,

Maintaining momentum

December 19th, 2008

First I’ll get some personal-goings-on out of the way.

As my previous post implied, I’m now quite happily working as a software designer at Sininen Meteoriitti, which just so happens to be the other one of the two companies recieving honorary mentions in the earlier industry-related rant.

Things are pretty good here. I’m surrounded by brilliant people and a refreshingly easy-going corporate culture. Programmers follow conventions meticulously and thus the codebase is clean and easy to get into. Not all of them are exactly radiating with passion, but it clearly is there nevertheless.

The company has reached a respectable size of 60 employees, but there still is a distinct air of work-in-progress about. That is by no means a bad thing. When there isn’t an answer to everything, you kinda get a chance to slip your own thoughts in.

I’m not saying that you really need any corporate tactics nor politics to get your voice heard here. The hierarchy is there but communication-wise it’s flat as a pancake.

So.

I was talking with the CTO the other day on MSN, trying to conjure up an idea for a blog post. The subject that kinda jumped at me was the challenge of keeping employees involved in the constant stream of new technologies.

Two prime motives for tackling this challenge

First, to keep enthusiastic and information-hungry people engaged to the company. People belonging to the aforementioned category (including yours truly) like to stay on the cutting edge and experiment with new things. Doing project work on the same platform for years on end – to me – seems like a valid motive for job-hopping.

Second, to keep your company on the cutting edge. This isn’t to say that you should embrace each and every new framework, O/R mapper or project methodology thrown at you – updating and refactoring your existing codebase to support new technologies all the time is an easy way to waste money and keep the bug tracker busy – but you definitely should stay on top of things. This is a vast subject on its own, and better covered elsewhere, so I won’t go deeper into it for now.

So what can you do to keep your staff educated?

There’s the traditional approach of sending people off to courses and seminars. A good approach as such, but I’ve often found it somewhat slapdash in execution. Sending an employee off to a crashcourse on WPF is merely driveby-education if you don’t provide means to apply that freshly acquired knowledge on anything. Slightly problematic, taking into consideration the fact that the first client case shouldn’t hastily be seen as a concoction to acid test Ruby On MonoRailCat 0.02 Community LOL Preview in.

However, I’ve yet to see or hear about a software company that has its own toolset fully covered and refined. The shoemaker’s daughter has no shoes and all that. Internal development is a great field to test one’s skills at and really learn the practical ins and outs of new technologies. A typical example of this is the dreaded timesheet application. Every software company needs one and everyone needs it to be just slightly different than the other one.

Sending an employee off to a course and then giving her the chance to apply the freshly learned skills onto something relevant – but not too critical – is a really great way to keep an employee’s skillset up to date and bring a breath of fresh air to the job.

An idea of a slightly more comprehensive and academic approach came from our brilliant CTO, Jouni Heikniemi. He proposed that I could perform a speech to the company on the subject of a technology I’ve had my eye on for some time now, namely Microsoft Oslo. The idea being that I first have to learn a thing or two about the said technology.

Needless to say that learning a technology to the point that one can confidently speak to an audience about it should develop a pretty good understanding on the subject. However, the trick here is actually to make a project out of learning and allocate some time and resources to it.

Lastly, there’s the Google way: 20-percent time. It’s about giving the employees a chance to work one day a week on stuff not necessarily in their job descriptions. Funding employee-driven open source projects seems like a good idea to keep employees experimenting and innovating. It doesn’t have to be 20%, nor does it have to be any other statically defined amount of time. Encouragement and allocating time on need is enough.

The 20-percent time principle somewhat overlaps with the first technique, and indeed the way forward could be to let the employee think of her own projects, but if none emerge, she could be given an internal development project to fiddle with the way she likes.

To boil it down, there isn’t a silver bullet here, but I think you’ll agree that people should be given the time and possibilities to educate themselves and apply the knowledge on at least something. But even more than simple methods and principles, the constant education process requires the right atmosphere.

Encourage. Inspire. Host your own techdays. Build an extensive library.

P.S. My blog scored a fancy caricature of my hairy mug. Thanks go to Janne Itäpiiri for that.

bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Technology