Thermodynamics and developers life’s

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.

Posted in personal | Tagged , , | Leave a comment

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

Ya esta publicada el video de la VAN acerca de ASP.NET 4.5 (o vNext) y Visual Studio 2011 para web developers. Esta es la primera de dos VAN’s acerca de los cambios en la nueva version de ASP.NET y como sacar ventaja de ellos. Al final de las diapositivas hay una lista de recursos en los cuales pueden profundizar mas acerca de este tema. Gracias a Alt.Net Hispano por la oportunidad de compartir con ustedes.

Unable to display content. Adobe Flash is required.

Si quieres saber mas acerca de las VAN para la comunidad de Alt.Net Hispana acercate a su homepage, tienen de todo para todos =)

Y claro esta, las diapositivas usadas:

Referencias:

Posted in talks | Tagged , , , , , | 1 Comment

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

Posted in development | Tagged , , , | Leave a comment

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/

Posted in development | Tagged , , , , | 1 Comment

A week extending Expression Blend–The basics

Expression Blend is an amazing piece of software. It is created with the same philosophy as awesome products like Visual Studio.That is, there is only a simple shell with common and very clear extensibility points and everything else (the designer, the toolbox, even the compiling process) is written as an extension to that shell. Personally I like that way of thinking about such a complex application, you can easily designate a team to create the shell and many different teams to create all the functionality around your main application as extension to the main application, even better, you expose your main application as an composite application in a way other developers or companies can take advantage of that and even create an ecosystem around your application. Imagine applications such as CRM’s, accounting software or even tools like word processors taking advantage of that.

Well, Expression Blend 4 (and the whole Expression Suite by Microsoft) is created around this principle using the Microsoft Managed Extensibility Framework (MEF)http://msdn.microsoft.com/en-us/library/dd460648(VS.100).aspx to handle extensibility concerns. I strongly recommend to become familiar with the principles around MEF and take advantage of this amazing framework. Before Expression Blend 4 Microsoft used MEF “kind of predecessor” the Extensibility Add-In Framework in the .Net Framework 3.5 (available also in 4.0 of course). So with this in mind we need to differentiate between two different types of extensions in Microsoft Expression:

  • Add-Ins: It’s the old way to extend Expression, this model is available from Expression Blend 2.0 to Expression Blend 4.0, it’s not as flexible as the Extension model but together expose the same functionality and works almost in the same way. If you need to support versions before 4.0 this is the model you need to use.
  • Extensions: It’s the new way and uses MEF as extensibility mechanism. If you love things like Inversion of Control and auto discovery this is the model you need to use. It is very similar to the Visual Studio Extensibility Model and I hope one day in the future both models would merge together (so we can share extensions from one package with the other, just imagine that, well, I can dream). We are going to use this model for our samples and mention the differences with the classic Add-In model when necessary.

A primer to MEF

MEF is the extensibility core for Microsoft Expression Suite, it’s an amazing framework to handle concerns about discovery, dependency, lifetime and registration of components for extensions. This framework is used by other Microsoft products like Visual Studio. We are not going to cover the usage and basics around MEF, but before continue with the series I strongly recommend you to take a look at some basic MEF tutorials like the simple tutorial written by Brad Adams or the walkthrough in the MEF home page in Codeplex. Go ahead, take your time and have fun with the joy of using MEF.

UPDATE: After publishing the post I just realized a big mistake in it, MAF (Managed Add-In Framework) it is not MEF predecessor, it’s just another “application extensibility model” different than MEF, maybe in the next future I will talk a little more about it. Sorry for my mistake!

Posted in development | Tagged , , , , | 1 Comment