C# Fundamentals – Delegate Basics Part 1

From time to time I like to visit the opposite end of the spectrum from high-falutin’ software architecture topics, and examine the basics of such topics as C# language, OOP, SQL, JavaScript, HTML5, jQuery, CSS3 etc. Of course there are gazillions of technical articles and tutorials on such subjects; one of my favorite sites for basics is w3schools.

They do a great job. There are a lot of other articles/tutorials, however, that are not that great. Some are so basic that they don’t really leave you with a feeling that you have grasped the topic, and others start right off with complex examples that are hard for beginners to understand.

This post will begin a series of tutorials on C# language fundamentals, in particular some topics that are typically hard for beginners to get a handle on. They will be packaged in the form of complete and functional VS2013 solutions zipped up, so that all one needs to do is unzip, open the solution in VS2013 (any licensed version of VS2013, or you can download Visual Studio Express 2013 for Web for free), and press F5 to execute.

And, in most cases for these fundamental tutorials (as opposed to architecture topics), all of the actual text of the tutorials will be comments right in the source code that you will examine and execute. In this blog post I will just provide a brief summary of what the tutorial is about.

C# Fundamentals – Delegate Basics Part 1

We begin with a discussion of delegates. This is historically a difficult concept for some to grasp. There are step-by-step, “from scratch” examples, explained in the simplest and clearest way possible. Upcoming tutorials will focus on other topics that beginners to C# and/or coding in general, find difficult such as the use of delegates as callback functions and event handlers, and events themselves.

The VS2013 solution for this tutorial can be downloaded from:



Unit of Work & Repository Framework video – Review

Recently I found a really cool YouTube technical video, “Unit of Work & Repository Framework” by a Microsoft MVP named Long Le. One of the most amazing things about this 21:30 long video is how much ground he covers in it. Here is a link to his blog about the video (link to the YouTube video is in the blog entry):


Here are the main topics he touches on:

  • Entity Framework Power Tools
  • Uow & Repo Framework
  • Generating EF Mappings and POCO’s
  • Upgrading the stack to EF 6.2
  • Basic Customer CRUD Use Case with MVC Scafolding Template w/ Async
  • Refactoring the CustomerController to use UoW & Repo Framework w/ Async
  • Why the ICustomerService Approach?
  • Why Commit Unit of Work Outside the Service vs. versa
  • Quick Examples with Eager Loading, Filter, and Sorting

What is more amazing than the number of topics he covers in 21+ minutes is that he manages to do so in a very clear, understandable way.

But what is even better is that the framework he has created is available on CodePlex, for anyone to download and use (and change/extend for their own requirements).  The CodePlex link is:


The parts of the video I found most useful were when he was actually in the code, and showing how the generic, UOW repository layer over Entity Framework was injected into an MVC controller using the Unity dependency injection container.

The dependency injection pattern in general, whether one implements it manually or uses an Inversion of Control container such as Microsoft Unity, Ninject, or Castle Windsor (to list a few of the major ones) is a pattern that all senior developers/architects should consider utilizing in any large/complex software applications to reduce coupling of software objects/components/layers.  For one thing, it can make testing (particularly mocking) much easier – but utilizing dependency injection is another whole discussion.

One word about Unity…  Having done a bit of research comparing those three particular IoC containers, I am comfortable nowadays using Unity because its most recent version, Unity 3, seems pretty solid (I wouldn’t have used Unity 1.0, but then isn’t that typical of Microsoft software products!).  Ninject has not been updated since March 2012, which seems like a long time at this point. To be fair to any other products like Castle Windsor and a couple of others, I haven’t checked them out thoroughly – but at this point I am fine with sticking with the Microsoft component (and of course there are the obvious benefits of doing that).

But to summarize, I would highly recommend watching Long Le’s video.  If you are a software developer and/or architect, I guarantee you will be impressed.

The Command Query Responsibility Separation pattern

I just ran across the most impressive technical writeup on CQRS, the Command Query Responsibility Separation design pattern.  It is truly a master class on the subject.  It is actually a whole series of articles on the Microsoft Developer Network, in the patterns and practices area, entitled “CQRS Journey.”  The link is:


I would recommend downloading a pdf that contains the entire series of articles, which is at:


Unlike many other discussions of CQRS, this one excels in explaining the concepts behind CQRS and its closely-related cousin, Event Sourcing, in clearly understood terms and with lots of easy-to-understand examples and diagrams.  At the same time, plenty of actual C# code showing actual implementation details is also included. The various contributors to the series really did do a stellar job.

Anyone who wants to understand CQRS should start with this (I would actually recommend reading the first appendix, “Reference 1: CQRS in Context” first because it helps to at least have a high-level understanding of the major concepts of Domain-Driven Design (DDD), and then circle back around to the beginning of the series).

Even if all you knew about it previously was that CQRS was the name of a design pattern, you will come away with a good understanding of the concepts and if you are into advanced .NET application architecture, you will immediately begin thinking of ways that you might incorporate CQRS into your designs (particularly in large/complex systems and/or systems with significant load-handling requirements).