DCSIMG
ANAK.DOT-HA!
Ninject or Unity?
06 December 11 11:35 PM | גיא זרזבסקי | with no comments

It wasn’ the first time that I read about people preferring using Ninject for DI rather than other solutin , such as Unity by MS.

As I was searching for what people say, here are performance graphs of major DI solutions:

Plain DI (No params):

image

With ctor params:

 

image

 

Ninject is by far the slowest of them all…so who said MS can’t provide good solutions ? Maybe it’s the name “Ninjet” that makes people more…injected Smile

תגים:
Singleton Pattern or Static Class?
05 December 11 12:37 AM | גיא זרזבסקי | with no comments

Well, apart from having Google search really drawing all the attention towards Sasha Singleton, I doubt that this lady actually uses any of those solutions…

Anyhow, I was wondering what method should I use to keep my static data. As we know, we can :

1) implement a static class approach and use static ctor to initialize our static members

2) Use Singleton pattern:


public sealed class SashaSingleTon
{
    object[] _data = new object[10];


    static readonly SashaSingleTon _instance = new SashaSingleTon();

  
    public static SashaSingleTon Instance
    {
        get { return _instance; }
    }

    private SashaSingleTon()
    {
      
    }
}

Well, the latter seems to allow us more flexibility and the one thing I adore most is that SashaSingleTon can implement interfaces while the static approach can’t.

Other than that there are other issues of safe threading , using the singleton as a parameter etc…

image

I believe Sasha does implement ISingleTone , yet she is not my Type.Cast

תגים:
Who would have though I could do this?
03 December 11 11:21 PM | גיא זרזבסקי | with no comments

class Program
{

    public static void PrintFullName (IEnumerable<Person> persons)     
    {

    }

    public static void Main()
    {
        var emps= new List<Employee>();


        PrintFullName(emps);
    }
}

 

No need to explain what’s the use of this…

Well, thanks for c# 4.0 , I can now that there is support for variance for IEnumerable<T> (among other covariant interfaces)

Learn more: http://msdn.microsoft.com/en-us/vstudio/ee672319.aspx

תגים:, ,

This Blog

Syndication