Register Login

 

Welcome to the Coach Factor blog. Here you will find all of our ideas on software development. Subscribe at  http://blog.nventive.net.

# Saturday, May 17, 2008

For those of you who were at DevTeach Toronto and listened us talk about Enterprise Library 4.0 new features, we promised 4.0 was on the way. Well, it's officially released! You can get more information on Grigori's blog

Make sure to also look at what's new in the Unity 1.1 refresh.

Saturday, May 17, 2008 2:03:14 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
.net
# Tuesday, May 13, 2008

Umbrella is nVentive's attempt at filling the gaps in the existing .net framework and related technologies; hence reducing friction and increasing the predictability of the api.

It consists of a set of helpers and additional abstractions that will likely augment one's vocabulary and level of abstraction. This is the first drop of the framework, and we look forward to adding new modules, that will complement Unity, Enterprise Library, Entity Framework and more.

Go check it out on CodePlex (www.codeplex.com/Umbrella) and see how you can diminish your software's complexity by using new patterns.

Tuesday, May 13, 2008 8:28:02 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Announcement | Umbrella
# Monday, May 12, 2008

Hopefully, after reading Part 1, Part 2, Part 3, Part 4 and Part 5, you should've become an Extension Method Master.

But there's more. There are other elements that can be simplified by using extension methods and that is, limiting usage of reflection.

Given something like:

public interface IServiceLocator

{

  T Resolve();

}

 

It is important to notice that the generic method Resolve has a type parameter for the sole purpose of providing the type to resolve. There are NO constraints.

One might use the service locator as follows:

public ILogger GetLogger()

{

  ILogger logger = serviceLocator.Resolve<ILogger>();

 

  return logger;

}

But what if the type to resolve is only known at runtime? You'll have to fallback on reflection:

public static class ServiceLocatorExtensions

{

  public static object Resolve(this IServiceLocator locator, Type type)

  {

    MethodInfo resolveMethodInfo = typeof(IServiceLocator).GetMethod("Resolve");

    resolveMethodInfo = resolveMethodInfo.MakeGenericMethod(type);

 

    return resolveMethodInfo.Invoke(serviceLocator, null);

  }

}

This approach can have terrible performance, especially since there is no reflection cache.

A far better approach is to define your IServiceLocator interface as a non-generic interface and provide strongly-typed extension methods:

public interface IServiceLocator

{

  object Resolve(Type type);

}

and

public static class ServiceLocatorExtensions

{

  public static T Resolve(this IServiceLocator locator)

  {

    return (T)locator.Resolve(typeof(T));

  }

}

 

Thoughts?

powered by metaPost

Monday, May 12, 2008 2:04:40 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
.net | .net - Extension Methods
# Wednesday, April 30, 2008

Finding tools that can help you through your daily SCRUM meeting can be a hard task. Other than the usual rubber football that allows a person to speak, nothing else seemed interesting, that is until last week.

I was aimlessly surfing on CodePlex when I found TFS Sticky Buddy. It's a great way for your team to "see" the iteration. It's a small WPF program that visualizes the work items contained in a TFS Team Project.

TFS Sticky Buddy

As soon as I have time, I will try to implement this tool within my teams, because I believe that it is a nice way to focus the team, during the SCRUM meeting, on the iteration.

Wednesday, April 30, 2008 2:06:04 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Process

Yesterday I was helping somebody with a small WCF application and one of the tools I proposed was a plugin visualizer for Visual Studio called WCF Visualizers. It's available freely on CodePlex and will allow you to see different parts of WCF (messages, endpoints, channels...) while you are debugging. Go and check it out, as there are some great images on the project page. The next time I give a WCF presentation with Francois at different user groups, I will also take the time demo this tool.

Wednesday, April 30, 2008 2:05:22 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
.net
# Monday, April 21, 2008

nVentive was present in Quebec city at HEROES happen {here}, Microsoft's launch for Visual Studio.Net 2008, SQL Server 2008 and Windows Server 2008.

François and I were experts there on the developer side of things, and the one thing we got asked the most, were questions on LINQ.

Everybody knows that LINQ is the hot new way to query objects in C# using a syntax similar to SQL. It depends on 2 tricks, Extension Methods and Lanbda Expressions.

This is a small sample.

public class Blog

{

   public string Title { get; set; }

}

class Program

{

   static void Main(string[] args)

   {

      IList<Blog> blogs = new List<Blog>();

      blogs.Add(new Blog { Title = "3 cheese lasagna" });

      blogs.Add(new Blog { Title = "Blue cheese alfredo sauce" });

      blogs.Add(new Blog { Title = "Macaroni and cheese" });

      blogs.Add(new Blog { Title = "Angel cake" });

 

      var blogsWithCheese = from blog in blogs

            where blog.Title.ToLower().Contains("cheese")

            select blog;

      //blogsWithCheese contains 3 elements.

   }

}

You can query something that is IEnumerable with LINQ to Objects, or a database itself using LINQ to SQL. If XML is your thing, there is a LINQ to XML variant and let's not forget that there is adapter to query Ado.Net DataSets. If you've heard of Entity Framework, LINQ will also work there to abstract it's object SQL language.

Now there's still more, if you have a source that you'd like to query with LINQ, it's just a matter of implementing IQueryProvider and IQueryable.

There are 2 tools I recommend you use in your adventures with LINQ:

  1. LINQPad is a interactive LINQ learning tool. Check it out, you'll never go back into Query Analyzer after that.
  2. Visual LINQ Query Builder is a plugin for Visual Studio 2008 that will help you develop your queries with a designer, now that's practical.

Monday, April 21, 2008 8:33:18 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
.net | Announcement
Search
Archive
<May 2008>
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
Statistics
Total Posts: 47
This Year: 0
This Month: 0
This Week: 0
Comments: 2
Sign In