Archive

Archive for the ‘.NET’ Category

Client / Server Localization – Introduction

January 25th, 2012
Daniel Marbach

This is the introduction posts about dynamic client / server localization which describes the problem domain. In one of my current projects, we are building a client / server application that uses windows communication foundation requests and responses and event driven data, which is fired over the distributed event broker. Some of the data is dynamically rendered on the client but needs to be translated into several languages. For information which is already known at compile time localization is really straight forward with WPF. But what about data which is not known at compile time of the client?

read more

 

.NET , ,

Structure your code by feature

January 25th, 2012
Urs Enzler

cross-post from bbv blog

When software projects grow both in age and size the developers often struggle with the structure of the code. It gets more and more difficult to find the class you have to change for a new requirement. In this post, I’ll show you how we organize our code and how we derive our structure directly from the requirements.

read more

 

.NET, Agile, Architecture, Clean Code, Methodology, Test Driven Development , , ,

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

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

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

xUnit Cheat Sheet

December 4th, 2011
Daniel Marbach

Here is a draft of my xUnit Cheat sheet

Update: 06.12.2011, added IUseFixture<>

xUnitCheatSheet (Currently V0.2)

Let me know if you have any updates…

 

.NET, Test Driven Development, Testing ,

bbv.Common.Bootstrapper Tutorial Part 3

December 4th, 2011
Daniel Marbach

Behaviors

Behaviors allow extending the bootstrapping process in an aspect oriented style. Behaviors gain access to extensions which are participating in the bootstrapper process and can therefore influence them for example by injecting additional runtime information into an extension. Behaviors must implement IBehavior<TExtension>. They automatically gain access to all extensions participating the bootstrapping process. Behaviors are executed before the corresponding extension point is called. read more

 

.NET , ,