Browse by Tags

All Tags » C# (RSS)

Log message Request and Response in ASP.NET WebAPI by Fredrik N

By logging both incoming and outgoing messages for services can be useful in many scenarios, such as debugging, tracing, inspection and helping customers with request problems etc. I have a customer that need to have both incoming and outgoing messages...

Design by Contract with Microsoft .Net Code Contract by Fredrik N

I have done some talks on different events and summits about Defensive Programming and Design by Contract, last time was at Cornerstone’s Developer Summit 2010. Next time will be at SweNug (Sweden .Net User Group). I decided to write a blog post about...

Use Extension method to write cleaner code by Fredrik N

This blog post will show you step by step to refactoring some code to be more readable (at least what I think). Patrik Löwnedahl gave me some of the ideas when we where talking about making code much cleaner. The following is an simple application that...

.NET 4.0 is so Lazy by Fredrik N

With .NET 4.0 there is a new class added to the System namespace called Lazy<T>. This class is what the name says, lazy. Here is an example where Lazy is used: var lazy = new Lazy<IList<OrderRow>>( () => { var rows = //get order rows;...
Filed under: , ,

Is it important to write good code? by Fredrik N

The last three weeks I have visit several companies and talked about writing good code. It's amazing to see how different developer thinks about writing good code. Here are some comments when I asked if it's important to write good code: - I don't care...
Filed under: , ,

Region is an excuse for hiding large files by Fredrik N

Often when I take a look at sample code there are a lot of regions. I need to open them all the time, it really start to make me crazy. Why does people even use Region in their code, what's the point of hiding code? I think it's only an excuse to hide...
Filed under: , ,

Map Objects to one Object by Fredrik N

In my previous post I wrote about how we could use Dynamic Compilation for mapping object to object in a configuration file, mosly for fun to simply try something different. I spend a few minutes to see if I could do something more with it. It ended up...
Filed under: ,

The configurable application, no need for recompilation and new deployment! by Fredrik N

The following I will write about is something I have used in some projects to see if it gives me any value, I haven't seen any evolutionary results yet, but maybe it's because I often move along to other projects when the previous one is completed ;)...
Filed under: , , ,

Remove code smell with AOP by Fredrik N

During the last years you have probably heard about Aspect Oriented Programming (AOP). Different people like or don’t like AOP. I’m one of them who like AOP. As you may now VB.Net and C# are object orientated languages and with object oriented programming...
Filed under: , ,

Multiple return values, I want this in C# by Fredrik N

I so badly want to have support for multiple return values in C# instead of using out parameters. Note: The following is only an example, we can use a struct or an object to create a data structure which will hold the value, but I only use this code for...
More Posts