Spend time learning technologies that have been around for awhile

And the longer a technology has been around (and is still being actively used) the more important it is to understand it.

Sometimes I think there is a general fear that devoting too much time in learning something that has been around for awhile could be wasted time the minute a cutting-edge technology claims to replace it.

However, we should remember that the cutting-edge technology has not stood the test of time. It may well fail.

Also, there is a reason the cutting-edge technology exists. The creator(s) of it had to already understand the old school tech. that it is replacing. A thorough understanding of that technology provides a context within which the cutting-edge technology can be understood in terms of motivation/intention, which is precisely the context within which a decision can be made as to whether or not the new tech. is the real deal/should be adopted/etc.

Advertisements

Asynchronous Life

Been thinking about asynchronous programming lately. When I’m learning something new and complicated–in this case, very complicated–I like to try to integrate the concepts with other concepts that I currently understand (or think I do).

So an asynchronous call is like email. You fire off your email and [then should] immediately continue on with your work. Certainly, when you get a response, you may well use it and do stuff with it, but until then, you can work on other things.

On the other hand, a synchronous call is like IM. When you’re in an IM conversation with someone, you are waiting on them to provide a response before you can continue.

I would say that communication using Twitter is asynchronous in nature, the number of API calls/minute has increased to the point where we can choose to “block the caller” (stare at Tweetdeck) until a response is received.

—————————-

Off-topic: I really think threads should not be abstracted away when doing concurrent programming. How else does one explain the difference between synchronous and asynchronous programming? Threading and multiple call stacks should actually be the conceptual foundation upon which we learn about and understand programming and program execution.

It is key to understand an executing program as a running process and not as something that persists by itself through time. I’ll probably write a post about this and end up incorporating my full-blown process ontology into it. (Why did that last clause sound so dirty?)

Write code that is easy to change

It’s risen to #1 on my list of things to remember when writing code. When I write something, I want to be able to change it easily and remove it easily. Every single line I write is outdated as soon as I write it, so rather than it being a new addition to the codebase, I view it as a decaying corpse that absolutely must be replaced at some point.

Far easier to remove a corpse that’s already in a bodybag than one which a hundred other fresh corpses rely on to stick around, right?

ILMerge with .NET 4.0.

If you are getting an “Object reference not set to an instance of an object” when running ILMerge from the command line, ensure that you have quotes around the target platform, like so:
/targetplatform:'v4, C:\Windows\Microsoft.NET\Framework\v4.0.30319',

not

/targetplatform:v4, C:\Windows\Microsoft.NET\Framework\v4.0.30319.

Uhh… is this thing on (still)?

Apparently blog posts don’t write themselves. Hmm. Whatever. Here’s a PowerShell script that will update all projects that are under source control in a directory (the directory is set inside the script):

# Directory of projects under source control
$projectsDir = 'C:\Dev\Third Party'

function Progress([string]$projectName, [system.action]$update)
{
    $activity = "Updating projects in " + $projectsDir + "..."
    $status = "Updating " + $projectName
    write-progress -activity $activity -status $status
    $update.Invoke()
}

# VCS update directory-command dictionary
$commands = new-object 'system.collections.generic.dictionary[string,system.action]'
$commands.Add(".svn", { svn update })
$commands.Add(".git", { git pull })
$commands.Add(".hg", { hg pull })

# Main
clear
cd $projectsDir
$dirs = ls | Where { $_.psIsContainer -eq $true }
foreach ($dir in $dirs)
{
    cd $dir
    $subdirs = ls -force
    
    foreach ($subdir in $subdirs)
    {
        if ($commands.ContainsKey($subdir.Name))
        {
            Progress $dir $commands[$subdir.Name]
        }
    }

    cd ..
}

You can add more $commands for your favorite VCS, if you wish. Note that this will only update one level of subdirectories (to stay compatible with Subversion… I think.)

An Ordinary First Post

Using an IoC container enables me to change the greeter’s language by changing one line of code.

namespace xofz.BlogCode.Sup
{
    using System;
    using Ninject;
    using Ninject.Modules;

    static class EntryPoint
    {
        static void Main()
        {
            var module = new GreeterModule();

            using (var kernel = new StandardKernel(module))
            {
                var greeter = kernel.Get<IGreeter>();

                greeter.SayHello();
            }
        }
    }

    class GreeterModule : NinjectModule
    {
        public override void Load()
        {
            Bind<IGreeter>().To<EnglishGreeter>(); // this is the line of code I would change
        }
    }

    interface IGreeter
    {
        void SayHello();
    }

    class FrenchGreeter : IGreeter
    {
        public void SayHello()
        {
            Console.WriteLine("Bonjour!");
        }
    }

    class SpanishGreeter : IGreeter
    {
        public void SayHello()
        {
            Console.WriteLine("Hola.");
        }
    }

    class EnglishGreeter : IGreeter
    {
        public void SayHello()
        {
            Console.WriteLine("WAZZAAAAAAAAAAAAAAAAA");
        }
    }
}

However, every single post in this blog will be in English, so you may prefer the simpler:

namespace xofz.BlogCode.Sup
{
    using System;

    static class EntryPoint
    {
        static void Main()
        {
            Console.WriteLine("Good day.");
        }
    }
}

Nevertheless, expect future posts to include lots of code utilizing IoC containers.