Special Offer: My C#/.NET Bootcamp Course is out now. Get 10% OFF using the code FRIENDS10.

Today I will provide you with a review of Filip Ekberg‘s first book called C# Smorgasbord. To get an explanation of the term Smorgasbord, visit Wikipedia. As the first two characters of the title suggest, this book contains valuable information about C# development.

C# Smorgasbord Cover

This book consists of approximately 280 pages and contains twelve mostly independent chapters about topics like Parallel Extensions, unit testing, mocking, upgrading your existing (legacy) code, asynchronous programming, dynamic programming, code readability, reflection, Roslyn, Inversion of control and many other pretty cool things.

Who this book is for

According to the description on the first few pages in the book, this book is written for beginners as well as experienced software developers. Since I can describe myself as an advanced developer, I think there are chapters which go way too deep for beginners. But it could be an impressive way to start with to get an overview of all the great things C# offers us. So I won’t tell you not to buy that book if you’re completely new to C#, but don’t expect it to be a how-to program in c# book or something like that. For this purpose, there are many other books (available in its 3rd edition) which cover this topic more precisely.

About the author

Filip Ekberg is a senior software engineer from Sweden. He is mostly interested in C#; WPF, WCF and other Microsoft related technologies. He self-published his first book in August 2012. Because of his valuable postings on his blog, his book and many other things he did in 2012, he became Microsoft MVP for 2013.

Content in detail

Overview

First, I have to tell you that you can write an entire book about each of these chapters. What I like about this style of writing is that, you get an overview about the different topics. If you’re very new to all of them, you can decide which topics you’re mostly interested in and start doing some further study. If you’re more experienced, this book helps you to help others improve their knowledge. Some topics are explained in very few pages with good code examples.

Chapter 1 – Introduction to Parallel Extensions

The first chapter describes how you should think about parallelization and how to implement an activity in a parallelized way in C#. In addition, Filip gives us some mathematical background which I personally like very much. It does not cover the entire PLINQ or Parallel Extension framework, but it gives you a short introduction to these topics.

Chapter 2 – ProducTivity and Quality with Unit Testing

Chapter two focuses on why we have to write Unit Tests and which advantages we gain if we use them in a correct way. Furthermore, Filip describes how to start with Unit Testing. He presents the MSTest testing framework and gives a hint to NUnit. In addition, there is an introduction to Test Driven Development (TDD) using a well imaginable code example.

Chapter 3 – Is upgrading your code a productive step?

In this chapter, Filip tells us how we should decide whether we move our code base to a newer version of a framework or even to a completely new technology. He explains how you should make the decision based upon parameters like the current employees and the current maintenance cost. This could be very valuable information if you often have conversations with your manager, trying to explain why you need to do that refactoring before shipping.

In addition, Filip provides us with an introduction to ClickOnce, ReSharper and NDepend. I’ve known about all these tools, but Filip shows us again how important they are especially if you work with a large legacy code base.

Chapter 4 – Creating a challenge out of the trivial tasks

This chapter is mostly about improving yourself. How can you write better code, even if you have solved a certain problem a hundred times? There are many ways and Filip mentions the most important things. He says that if you constantly improve your code base in very tiny steps, you’ll get a software with a much higher quality in the end. I think this is pretty true.

Chapter 5 – Asynchronous programming with async and await

First of all, there is a definition of parallelism and asynchrony. I think it is a very common mistake to mix them up. Therefore it is very important to understand the difference between them and how they relate to each other.

Next, Filip shows us an example and its evolution from using a BackgroundWorker, Task Parallel Library and finally the new async await pattern from .NET 4.5. This example demonstrates the advantages of the pattern in an understandable way and in only a few pages.

At the end of the chapter, there is a short guide on how to refactor an existing synchronous application to introduce asynchrony. This is definitely a real world scenario which most of us will experience and therefore should be prepared.

Chapter 6 – Dynamic programming

The entire chapter is an introduction on how to make use of the dynamic type. It also covers the problems which could be possibly introduced by using them. It also covers the possibility to interact with IronPython.

Chapter 7 – Increase readability with anonymous types and methods

This chapter is much about the readability of your code and how anonymous types can improve the style of your code. Filip introduces the most used delegate types such as Action and Func and also explains how they work and how you could make use of them to create a better designed solution.

Chapter 8 – Exploring Reflection

This chapter provides us with an introduction to Reflection and its common types such as MethodInfo, PropertyInfo, Type and many other classes. He shows how to implement some easy things but doesn’t forget to mention what risks to take by using Reflection. According to Filip, you can slow down your programs if you use it the wrong way. Unfortunately, he doesn’t mention exactly, what’s the wrong way.

Chapter 9 – Creating things at runtime

This chapter is a bit challenging if you have never worked with dynamic before as it seems to me. This chapter is all about IL, OpCodes and how to dynamically compose methods to call them in a dynamic way. If you were ever curious how this is achievable with C# or if you plan to work on embedded projects, this could be interesting for you. For me, it was an introduction to something new but not very relevant for the daily business.

Chapter 10 – Introducing Roslyn

This is one of the chapters I was most curious about. I’ve rarely heard the term Roslyn, but never started to investigate it further. And as I expected, this chapter contains a short but impressive introduction to Roslyn. Roslyn is currently in the CTP (Community Technology Preview) phase and can be installed by using NuGet.

Rosyln gives you the ability to analyze your code in a comfortable way, never seen before. You can analyze your code like ReSharper does, but to satisfy your specific requirements. If you have some domain specific patterns in your code which you want to get rid of, you can possibly write your own plugin for Visual Studio to make them visible as compiler warnings or similar. This way, it is easier for your developers or your colleagues to avoid them in the future or to rewrite a specific area of existing code.

This technique definitely has chances of changing the way we develop our code in the future.

Chapter 11 – Adapting to Inversion of Control

This time Filip shows us the concept of Inversion of Control. He does this by using a simple WPF application and transforms the code step-by-step to a complete demonstration of Inversion of Control. He explains the theory behind the concept but shows some straight forward code. I personally like this way of presentation.

Chapter 12 – Are you Mocking me?

In the final chapter of the book he shows us how to use the mocking framework, Simple.Mocking. In addition he explains what a mock is and how to use it for better and easier automated testing.

Conclusion

It was definitely worth reading the entire book. If you’re an experienced developer and read through the content table, you’ll first think that you know about all these topics. But when you read through a chapter in detail, you’ll find out that there is something new to you.

Recommendation

I would recommend this book to any team member who wants to understand the elementary things of modern and professional software development. It is definitely not a guide to redemption, but it’s a good way to start with. Normally you have to read through thousands of pages to get all these topics, but Filip offers a way to get all these elementary information in 280 pages. I like this very much.

After reading through the entire book, you can go a step further and buy a book about the topic you’re mostly interested in.

Buy on Amazon

 

Claudio Bernasconi

I'm an enthusiastic Software Engineer with a passion for teaching .NET development on YouTube, writing articles about my journey on my blog, and making people smile.