Reviewing The art of Unit Testing with Examples in .NET, by Roy Osherove

From time to time I like to spend some time reading up on a subject that’s work related. Today I’ve finished the art of unit testing, with examples in .NET, by Roy Osherove:

The art of unit testing with examples in .NET

Unit testing has become an important aspect of software development and as a developer I should be able to write good and maintainable unit tests. To be able to do so, I need to understand the basic concepts about unit testing and that’s why I bought this book.

Personally I think the book did a good job in explaining the basic concepts of Unit Testing:

  • Why unit testing
  • Fakes: Mocks and stubs
  • How to design code for unit testing
  • Why and how to use mocking frameworks
  • Best practices on how to organise your unit tests / integration tests
  • Trustworthy, maintainable and readable tests

However, there were also some points I found somewhat irritating:

  • Roy Osherove is also designed Typemock Isolator, a commercial mocking framework. Throughout the book you’ll notice a bit too much commercial sales about his product.
  • I had the feeling that some things were repeated multiple times throughout the book

The book is a great introduction into unit testing, and it’s clearly written. The book doesn’t go into technical depth, which makes it an easy and fast to read book. However don’t expect you’ll be able to just write all sorts of unit tests for real world applications after you’ve read this book. You’ll understand the basic unit-testing concepts and have a changed mindset towards unit testing. From that point on, it’ll be by practical learning experience. I’ll let you know within a year how that’s going 🙂

I would rate this book 3,5 out of 5.

Cheers,
Robbin

By Robbin Cremers Posted in Books

Customizing the Windows Azure Access Controle Service identity providers login page to something feasible

About a year ago, I wrote a blog post about how to easily integrate some external identity providers like Facebook, Google, Hotmail into your web application through the Windows Azure Access Control Service (ACS). You can find the information here:
Using Windows Azure Access Control Service to provide a single sign-on experience with popular identity providers

I will not explain what ACS is or what it is used for. You can find all that information in the previous post. The only thing that is different these days is the layout of the Windows Azure portal, which now looks a bit different because of the HTML5 layout. The Windows Azure Access Control itself has not changed, so it shouldn’t be much of a problem to create an ACS namespace and manage it.

As discussed in my previous post about ACS, you can download the ACS login page and customize this within your own web application. Using the identity providers login page hosted on ACS itself is not much of an option to be honest, because it simply doesn’t fit properly into your application. As shown in the previous post, you can download an HTML sample page that will manage the identity providers you have enabled into ACS. This post will prolong onto that specific topic.

When you download the ACS HTML login page, you get an HTML page with a bunch mumbo jumbo javascript in which will just hurt your eyes. By default the login page will look like this:

Windows Azure Access Control Service Authentication and Authorization

Making it look like something like this is a bit more feasible:

Custom Windows Azure Access Controle Service login page

Continue reading

Reviewing Design Patterns: Elements of Reusable Object-Oriented Software by the Gang of Four

It’s been half a year since I’ve acquired this book and it has taken a huge effort to go through the book. The Design Patterns book is a highly recommended book within the IT industry and has been labeled as on of the most influential books towards code quality. On amazon the book has a full 318 customer reviews of which 216 rate this book 5 out of 5. The statistics speak for itself and that’s also the reason why I bought this book:

DesignPatterns

Many of the reviews state if you are a developer, this is a must-read book. Improving your code with design patterns, a wisdom distilled though experience of others, will make you write better code. After having done some maintenance, I have to agree on the fact that everyone can write code that works but that the difference in quality and readability of code can be huge. However, this book has been published in 1994, which makes the book almost 20 years old. The examples in the book are mainly written in c++ or Smalltalk which might make the book sometimes harder to read if you only know how to write c# or VB.NET. Many of the Use Examples of some of the Design Patterns give examples of uses of 20 years ago, which will be totally unknown to you. How am I supposed to know a text editor of 20 years ago ?

Perhaps I’m not the fastest learner, but I found this book quite difficult to get through. Some of these design patterns are not always that easy to grasp and some of the patterns are quite related, which sometimes makes it difficult to see the clear separation. The Design Patterns book is not light-reading … I’ve had to reread some patterns multiple times to realize I still barely grasp the concept because I have no experience with it and have a hard time relating it to current examples. Not to mention if you read through 23 design patterns, you’ll probably almost forget half of it again within the next 2 months. This book is not a book you’ll be reading every evening because you just can’t stop reading it, unless you’re really goofy. For me personally, it was a struggle to keep reading the book and multiple times I caught myself picking up another book because I just kept losing interest in it.

At some point I was disappointed with the book, but as many have stated before me, it’s a good book to grasp some object-orientated concepts. However I would not immediately recommend this book to other people and definitely not to a starting developer. Even though the concepts of some of the design patterns should be widely known by developers, I believe there perhaps might be books out there better suited to get the hang of design patterns, with familiar code,  familiar examples and common uses.

I’m quite confident that I will be picking up this book again in the future to check up on a pattern again. Even though many people rate the book a 5 out of 5,  I would rate this book a 3/5.

Cheers,
Robbin

By Robbin Cremers Posted in Books

Reviewing the developer bible: Code Complete, Second Edition, by Steve McConnell

When searching for recommended books for developers, Code Complete always made the recommended book list. A lot of industry experts, for which I have high admiration, suggest Code Complete as one of the must-read books. I mean … if these people say this book is a must-read, who would I be to discuss that. Unnecessary to say, Code Complete 2nd Edition made it to my real Bookshelf.

Code Complete Second Edition

The first edition of the book was published in 1993, while the second edition was published in 2004. At first, I was really sceptical about this book, whether it was still up-to-date since this book has been around for almost 2 decennium.

However, there is not discussion possible. This book rightfully deserves it’s title as one of the must-read books as a developer. The book focusses mainly on software construction and managing complexityProgramming style and code readability are discussed thoroughly. The examples in this book are mainly in c++, Java or Visual Basic, but they are understandable for people not familiar with those languages.

There is not much to be said about it … If you have not read the book, you might just aswell buy it. You won’t regret it!

Cheers,
Robbin

By Robbin Cremers Posted in Books

Reviewing Framework Design Guidelines: Conventions, Idioms and Patterns for Reusable .NET libraries

I finally managed to get through the Framework Design Guidelines book, written by the people behind the .NET framework. They explain their experiences and insights on 4 versions of the .NET framework though a series of guidelines, that are being used by the Microsoft for the development of the .NET framework:

Framework Design Guidelines

The guidelines are provided in the following chapters:

  • Naming guidelines
  • Type design guidelines (Reference vs value, classes vs structs, abstract classes vs interfaces, static, …)
  • Member design guidelines (Methods vs properties, member overloading, optional parameters, params, ref, in and out, enumerations)
  • Designing for extensibility (Sealed vs unsealed, private vs public vs protected, events, virtual, …)
  • Handling exceptions
  • Usage guidelines (Arrays vs collections, ICloneable, Nullable, Object methods, …)
  • Common design patterns (Async pattern, IDisposable pattern, Factory pattern, Template method pattern, …)
  • Coding style conventions (brackets, spaces, indenting, comments, regions, …)
  • FxCop or Visual Studio Code Analysis

Continue reading

By Robbin Cremers Posted in Books

Reviewing the pragmatic programmer, from journeyman to master, by Andrew Hunt and David Thomas

I finished reading the following book “The Pragmatic Programmer” by Andrew Hunt & David Thomas.
The book was published on October 20 1999, yet 13 years later, this book is still one of the renowned books for developers to read.

It’s a short 300-page book looking like this:

The pragmatic programmer

This book is not for people who look for language guidelines, framework information or what tools to use. It does not explain how to build web or desktop applications. It’s not a technical book whatsoever, but it discusses the mindset a pragmatic developer should have or work towards. The Pragmatic Programmer is a collection of ideas, observations, and recommendations for software developers, a philosophy on developing software.

Continue reading

By Robbin Cremers Posted in Books

Managing configuration settings for different environments with config transformations

When you create a new web application in Visual Studio 2010, you will by default get a configuration file like this:

Web.config transformations

The web.config transformations allow you to adapt your configuration settings for different builds or environments. We have all worked with development, test and production environments where our settings differ from each other like:

  • Database connection strings
  • Endpoints
  • Credentials
  • Domains
  • Application settings
  • Debug mode
  • Tracing
  • Folders or shares
  • ….

When working with different environments, you are bound to be working with different configuration settings. Web transformations allows us to transform our configuration file to the correct configuration file for the environment we want to publish to. By default we get a Debug and Release transformation file. We want to add a tranformation file for developent, test and production environment.

1. How to use web.config transformations to manage your different configurations

For demo purposes we will take a simple web.config file which looks like the following:

Using web.config transformations to manage configuration for different environments

This is the web.config file which is containing our development settings. We will start by changing our configurations by the Configuration Manager:

Continue reading

Serializing your javascript objects or collections to valid json to submit with an ajax-enabled WCF service

Recently, one of the things I found myself struggling a bit with, was submitting my javascript object collection to an ajax-enabled WCF service which was expecting a object or object collection of a certain type. At first I kept getting format errors because my self created JSON object collection was not formatted correctly and thus the object collection could not be parsed correctly by our ajax WCF service.

Suppose we have a very simple data contract:

Serializing javascript object collection to valid json for ajax WCF service

We have an AJAX-enabled WCF service, that has a method that accepts an ienumerable of our data contract:

Serializing javascript object collection to JSON for AJAX enabled WCF service

We can build our object in javascript with the available properties and serialize the array with JSON.stringify:

Serializing javascript objects to JSON with JSON.Stringify

The result of JSON.stringify on the javascript object array will be a JSON parsed collection of employee:

{“employees”:[{“Firstname”:”Robbin”,”Lastname”:”Cremers”,”Email”:”robbin.cremers@email.be”},{“Firstname”:”Scott”,”Lastname”:”Guthrie”,”Email”:”scrott.guthrie@microsoft.com”}]}

The other solution is to write your objects in the JSON format immediately, but that is not any fun thing to do. When you are starting to build complex collection with multiple object levels, writing the json format manually is almost impossible. JSON.stringify just does the work for you!

Cheers,
Robbin

Everything you need to know about Windows Azure queue storage to build disconnected and reliable systems

In my attempt to cover most of the features of the Microsoft Cloud Computing  platform Windows Azure, I’ve been recently covering Windows Azure blob and table storage. Today I’m reviewing the Windows Azure queue storage, which is often used to build disconnected and reliable systems:

Windows Azure Service Bus messaging with Publish/ Subscribe pattern with topic and subscription

The information about Windows Azure Blob storage:
Everything you need to know about Windows Azure Blob Storage including permissions, signatures, concurrency

The information about Windows Azure Table storage:
Everything you need to know about Windows Azure Table Storage to use a scalable non-relational structured data store 

Why using Windows Azure storage:

  • Fault-tolerance: Windows Azure Blobs, Tables and Queues stored on Windows Azure are replicated three times in the same data center for resiliency against hardware failure. No matter which storage service you use, your data will be replicated across different fault domains to increase availability
  • Geo-replication: Windows Azure Blobs and Tables are also geo-replicated between two data centers 100s of miles apart from each other on the same continent, to provide additional data durability in the case of a major disaster, at no additional cost.
  • REST and availability: In addition to using Storage services for your applications running on Windows Azure, your data is accessible from virtually anywhere, anytime.
  • Content Delivery Network: With one-click, the Windows Azure CDN (Content Delivery Network) dramatically boosts performance by automatically caching content near your customers or users.
  • Price: It’s insanely cheap storage

The only reason you would not be interested in the Windows Azure storage platform would be if you’re called Chuck Norris …
Now if you are still reading this line it means you aren’t Chuck Norris, so let’s get on with it.

Continue reading

Everything you need to know about Windows Azure Table Storage to use a scalable non-relational structured data store

In my attempt to cover most of the features of the Microsoft Cloud Computing  platform Windows Azure, I’ll be covering Windows Azure storage in the next few posts.

You can find the Windows Azure Blog Storage post here:
Everything you need to know about Windows Azure Blob Storage including permissions, signatures, concurrency, … 

Why using Windows Azure storage:

  • Fault-tolerance: Windows Azure Blobs, Tables and Queues stored on Windows Azure are replicated three times in the same data center for resiliency against hardware failure. No matter which storage service you use, your data will be replicated across different fault domains to increase availability
  • Geo-replication: Windows Azure Blobs and Tables are also geo-replicated between two data centers 100s of miles apart from each other on the same continent, to provide additional data durability in the case of a major disaster, at no additional cost.
  • REST and availability: In addition to using Storage services for your applications running on Windows Azure, your data is accessible from virtually anywhere, anytime.
  • Content Delivery Network: With one-click, the Windows Azure CDN (Content Delivery Network) dramatically boosts performance by automatically caching content near your customers or users.
  • Price: It’s insanely cheap storage

The only reason you would not be interested in the Windows Azure storage platform would be if you’re called Chuck Norris …
Now if you are still reading this line it means you aren’t Chuck Norris, so let’s get on with it.

The Windows Azure Table storage service stores large amounts of structured data. The service is a NoSQL datastore which accepts authenticated calls from inside and outside the Azure cloud. Azure tables are ideal for storing structured, non-relational data. Common uses of the Table service include:

  • Storing TBs of structured data capable of serving web scale applications
  • Storing datasets that don’t require complex joins, foreign keys, or stored procedures and can be denormalized for fast access
  • Quickly querying data using a clustered index
  • Accessing data using the OData protocol and LINQ queries with WCF Data Service .NET Libraries

You can use the table storage service to store and query huge sets of structured, non-relational data, and your tables will scale as demand increases.

If you do not know the OData protocol is and what is used for, you can find more information about it in this post:
WCF REST service with ODATA and Entity Framework with client context, custom operations and operation interceptors

The concept behind the Windows Azure table storage is as following:

Windows Azure Table Storage, a scalable NoSQL data store with OData support

There are 3 things you need to know about to use Windows Azure Table storage:

  1. Account: All access to Windows Azure Storage is done through a storage account. The total size of blob, table, and queue contents in a storage account cannot exceed 100TB.
  2. Table: A table is a collection of entities. Tables don’t enforce a schema on entities, which means a single table can contain entities that have different sets of properties. An account can contain many tables, the size of which is only limited by the 100TB storage account limit.
  3. Entity: An entity is a set of properties, similar to a database row. An entity can be up to 1MB in size