Monatsarchiv: April 2017

Write clean code instead of comments

Of course comments help to understand code. They are an essential part of the source code. But comments are an addition only. If you want to create readable and easy to understand source code, you have to focus on the … Weiterlesen

Veröffentlicht unter .NET, C#, Clean Code | Kommentar hinterlassen

Design patterns: Observer

The Observer design pattern is used when you want to define a one-to-many dependency between objects. In case one object changes its state, all its dependents are notified and updated automatically. In this design pattern you have two participants. The … Weiterlesen

Veröffentlicht unter .NET, C#, Design Pattern | 1 Kommentar

Linq vs Loop: Check whether item exists

Like in the previous article of this series I want to compare Linq with a classical loop. This time we want to look at the common use case to check whether an item exists. Again we want to use validated … Weiterlesen

Veröffentlicht unter .NET, C#, Clean Code, LINQ | Kommentar hinterlassen

Design patterns: Adapter

The Adapter design pattern, which is also known as Wrapper design pattern, is used to convert the interface of an existing class into an interface expected by the client. In such a case the existing class has an incompatible interface. … Weiterlesen

Veröffentlicht unter .NET, C#, Design Pattern, Softwaredesign | Kommentar hinterlassen

Don’t return null

If you write a function returning an object instance you have to think about the special cases. This may be error cases or maybe situations where no object instance can be found or created. In such cases you will often … Weiterlesen

Veröffentlicht unter .NET, C#, Clean Code | Kommentar hinterlassen