Archive

Archive for December, 2011

Ninject.Extensions.Factory introduction

December 31st, 2011
Remo Gloor

The new release of Ninject 3.0 comes with a new extension that adds support for factories to Ninject. It supports factory interfaces, Func and Lazy. In this blog post I will explain how they are used.

Why using factories?
The recommended way to use IoC containers is that the composition root of the application is the only place where the container is accessed. Unfortunately many application can’t create everything at once during the application start or at the beginning of a web/wcf request because not everything is known at this moment. Therefore these applications need a way to create new instances using the kernel at a later point. Preferably we want to do this without introducing a reference to the container. This is where factories come into play. Instead of injecting the kernel into classes that need to create new instances we inject a factory. This factory is responsible to create the new instances using the kernel. There are two ways to implement such a factory: A factory interface and as a Func or Lazy.
read more

 

.NET , , ,

New Features and changes of Ninject 3.0

December 30th, 2011
Remo Gloor

Ninject 3.0 release candidate has gone live. This release introduces some new feature and some changes in its behavior. This blog post will give you detailed information what has changed. It covers mainly Ninject core. Other blog posts that describe the changes and the new extensions will follow soon.
read more

 

.NET , ,

Pair Programming Stereotypes

December 27th, 2011
Urs Enzler

Over the last couple of years, I’ve done a lot of pair programming. Pair programming inside my team, at customer sites, in coding dojos and in my open source projects.

Pair programming is really a great and effective experience when performed by an pair of developers knowing how to pair program.

Unfortunately, you cannot just put two developers in front of a single computer and expect them to perform perfectly from the start. Pair programming has to be learned. Both developers need to learn the difference between being the driver (the one holding the keyboard) and the navigator. See here for details.

During my pair programming sessions I encountered some recurrent stereotypes, which I list in this post.

read more

 

Agile, Methodology

Different Flavours of Pair Programming

December 26th, 2011
Urs Enzler

Pair programming – two developers working together at a single computer – can result in better software written faster, but only if you know what you do.

Pair programming is not just sitting together and code as you would when being alone. Unfortunately, this is what most developers practice – resulting in a painful and ineffective experience.

To get most out of pair programming, you first have to know your setup.

read more

 

Agile, Methodology, Test Driven Development ,

No more development, TDD begins with MoreUnit

December 25th, 2011
Adrian Elsener

Do you program or do you already TDD? :)
If you prefer to do TDD you will love the eclipse plug-in called MoreUnit. It is as simple as powerful. All it does is executing tests from corresponding productive class and makes it very simple to change between them.
Just press Ctrl-J (like Jump) to jump from test to implementing class and the other way. Or press Ctrl-R (like Run) to run the test regardless if you are in the test or the implementation class. read more

 

Agile, Java, Test Driven Development , , , , , , , ,

Using Lazy for implementing IDisposable pattern

December 15th, 2011
Daniel Marbach

Implementing the dispose pattern according to IDisposable can be very tedious. Why not simply use the new Lazy<T> to get rid of some boiler plate code? The trick is to define a Lazy<Action> with a function delegate which calls a release method. As long as you don’t access the value property of the lazy type the release method is not called. Lazy<T> offers the possibility to check whether the underlying value has been created or not (property IsValueCreated). Therefore we can use this to check whether we already disposed the underlying resources. Let’s see how this looks like in code:

    public class SomeDisposable : IDisposable  {
        private Lazy<Action> dispose;

        public SomeDisposable()  {
            this.dispose = new Lazy<Action>(() => this.Release);
        }

        public void Dispose() {
            this.Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing) {
            if (disposing && !this.dispose.IsValueCreated) {
                this.dispose.Value();
            }
        }

        private void Release() {
            this.resource1.Dispose();
            this.resource2.Disconnect();
            this.resource2.Dispose();
        }
    }

Remarks: I left out the finalizer to not clutter up the code sample too much.

Happy lazy coding!

 

.NET ,

bbv.Common.Bootstrapper Tutorial Part 6

December 10th, 2011
Daniel Marbach

The reporting mechanism allows creating a full report of the bootstrapping process. To be able to report the bootstrapping process the process must actually run and a reporter must be present. By default the bootstrapper uses a null reporter which does nothing with the report. But it is also possible to hook in a report generator which creates Visio, Enterprise Architect or … (you name it!) diagrams.

A custom reporter must implement the reporter interface IReporter. The reporter receives an IReportingContext which contains all necessary information about the bootstrapping process. The custom reporter must be passed upon the construction of the DefaultBootstrapper<TExtension>. read more

 

.NET , ,

bbv.Common.Bootstrapper Tutorial Part 5

December 8th, 2011
Daniel Marbach

Configuration sections

The bootstrapper supports loading of configuration sections through behaviors. The behaviors responsible for loading configuration sections must be applied in the begin section of the run syntax.

ConfigurationSection

To be able to load configuration sections the ConfigurationSectionBehavior must be added in the strategy. read more

 

.NET , ,

Get bytes from ByteBuffer

December 6th, 2011
Adrian Elsener

Here I will show how to get bytes from a ByteBuffer. This isn’t as simple as it sounds. read more

 

Java ,

bbv.Common.Bootstrapper Tutorial Part 4

December 5th, 2011
Daniel Marbach

Strategy

The strategy defines the order of execution for extension points and behaviors. The custom strategy must inherit from IStrategy. For convenience, use the provided abstract base class AbstractStrategy{TExtension} which simplifies defining a custom strategy. The strategy could look like the following: read more

 

.NET , ,