Dennis Ritchie

Dennis_MacAlistair_Ritchie_Today I read very sad news, Dennis Ritchie is dead. A person that literally changed my life (I remember reading The C Language and trying to make myself clear what a pointer was). I decided to become a developer when I first started coding and using a Linux system years ago. Today one of my heroes is dead.

Even if you are not a programmer you cannot avoid using Ritchie’s legacy, the Windows operating system you are using? well, took many of its ideas from Unix, and it’s made in C. Are you using MacOSX? well, guess what, it’s made in C. Well, you are a PHP developer? PHP is made itself in C and it’s obvious where the syntax it’s coming from. Even “modern” C#/Java/Python/Ruby developers cannot avoid it’s legacy.

Sir, we are going to remember you with every line of code we write. We owe you too much to be able to measure.

Do you have a blog? Give Dennis Ritchie the tribute he deserved, the one the media won’t give him. http://t.co/bsFFbAA8

UPDATE: Saddest piece of code ever http://t.co/Xp5EmFRg

Thermodynamics and developers’ life

When I was in University my favourite class (or maybe the class that basically changed my perspective of many things) was Thermodynamics, maybe was my teacher (a really brilliant physics and chemistry professor) or maybe was the very abstract and practical examples. She spend most of the time in the class explaining basic things like the rain or the boiling temperature of beans in high altitude with equations and thermodynamic laws. Years after that I still remembering many of the concepts and even making observations based in what I learnt those days.

In the last year I’ve been facing so many different problems as a developer and consultant with different customers, different technologies, different use cases, so many different areas of knowledge. Today I was thinking about the ideas about Gibbs theories and I saw something interesting with my developer life and how they are related.

You’ll see, one day my professor just explained how the Gibbs free energy is related to the human body chemical reactions and how the Entropy is important in everything that happen in human life, including relations. So at the end everything concludes in a simple fact: “you will get the complete equilibrium when you die”. Many developers look for a constant equilibrium in their life’s, some of them spend many years doing the same and making themselves confortable with the same thing, same technology, same platform, same risks, maybe they expect to face tomorrow the same problems they faced today, maybe they are looking for a zero entropy in their developers’ life.

Personally I like the fact to learn new things everyday, to face new problems, new challenges, maybe it’s the fear to have zero entropy in my life and realize I’m just death.

Maybe you need a little more of Entropy in your working life, what do you think?

A little more about Human Thermodynamics.

VAN en Alt.Net Hispano–ASP.NET 4.5 y Visual Studio vNext

NLog and local application configuration

I firmly think one of the tools every developer should have and add to its applications is logging, you should be familiar with any logging framework (whatever you like) and use it, extensively. In my case I really like NLog, a logging framework created under the log4net principles and looking for minimize the friction caused by log4net configuration.

Recently a friend of mine asked me the following question:

As we have several apps created into the same output folder they all override each others Nlog.config files.
I was wondering what is the best approach for that? Should I provide nlog configuration in app.config file? it doesn’t let me name NLog.config differently….

This is a very common question, looks like they have many exe files in the same directory, and they are using a nlog configuration file to configure the logging. Of course, if you are running two applications in the same directory with the same nlog file the logging settings will be shared between both applications. The answer to this problem is easy, use an specific nlog file for each application. That means: if your application is named app.exe your specific application nlog configuration should be called app.exe.nlog. If you want to automatically rename the file after compilation it would be a good idea to create a post build action in your proj file to do so, easy and clean.

The order in which nlog locates the configuration is easy to remember:

  1. Configuration section in your application configuration (app.exe.config)
  2. Specific nlog file for your application (app.exe.nlog)
  3. nlog.config file
  4. nlog.dll.nlog file

There is more in the official nlog documentation

A week extending Blend–The first extension

I hope you enjoyed learning about MEF and started thinking about all the possibilities around it in your applications, awesome right?. Well, now that you know a little more about things like MEF catalogues and MEF exports we can freely start talking about the basics in creating an extension for Expression Blend.

By default all the extensions in Expression blend made by 3rd party developers would live in a MEF directory catalogue under the folder Extensions in the installed path of your Blend application (the same happen for Expression Web). To “register” our application we need to provide a special bootstrapper known as Package, this special class implement the contract IPackage and takes care of our extension initialization (you know, things like registering your own services or adding things to blend) and when everything finish, provide support for cleaning up routines.

I mention a very common word in software development, services, the base of Expression extensibility. Every time we expose a new functionality to Blend we need to create and register a service and of course we will be consuming other services in our extension. The way to access this service collection is through the contract IServices, it exposes two important methods: Load and Unload, well, we will cover some important exposed core services in this series but if you want you could start taking a look by yourself using any “decompiler” tool like Red Gate’s Reflector, Jetbrains’ DotPeek, Telerik’s JustDecompile or the now popular ILSpy. Go feel free to start playing with them.

Well, no more to talk, let’s create our first simple package

  1. Add a reference to Microsoft.Expression.Framework and Microsoft.Expression.Extensibility tell to Visual Studio to never copy those assemblies to output. Those assemblies are in the Expression Blend installation directory
  2. Add a reference to System.ComponentModel.Composition, this library is in the GAC
  3. Create a class library for your extension
  4. Tell to Visual Studio to copy the output directly to your Expression Extensions directory

CropperCapture[1]

  1. Specify your library will be named with the postfix .Extension, this is needed for the MEF Extension Catalog to load the assembly, sort of convention.

CropperCapture[2]

  1. To easy your development effort, tell to Visual Studio to run Expression Blend when you debug the extension.

CropperCapture[3]

  1. Write the code for your “Package”

The code for your package would be very simple, let’s output to the debug output a simple message

using System.ComponentModel.Composition;
using Microsoft.Expression.Extensibility;
using System.Diagnostics;

namespace SampleExtension01 {
    [Export(typeof(IPackage))]
    public class SamplePackage : IPackage {
        public void Load(IServices services) {
            Debug.WriteLine("Hey, I'm in!");
        }

        public void Unload() {
            Trace.WriteLine("Boo! time to go =(");
        }
    }
}

Now we just run the Extension and look, our package works!

CropperCapture[4]

There are some differences in the way we create and register an Add-In instead of an Extension, but I think the bloggers around there already pointed them.

Now, the next time we are going to start doing a little more complex things, I promise =)

Meanwhile I let you with some links to people who explain a little more about the same thing:

You can get my sample code from Bitbucket. https://bitbucket.org/cprieto/extendingblend

NOTE: The index of the series could be found here http://cprieto.com/index.php/2011/09/17/a-week-extending-blendintroduction/