Archiv der Kategorie: Clean Code

Linq vs Loop: Nested Loop

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 use case to handle data which contains nested data. Again we want to use validated … Weiterlesen

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

Clean Tuples

Depending on the preferences of a developer you may sometimes find a lot of tuples within the source code. Whether this is good or bad practice is another discussion which is not part of this article. Therefore I don’t want … Weiterlesen

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

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

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

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

Design patterns: Iterator

An Iterator provides a way to access the elements of an object sequentially without exposing the underlying representation. It is a base Design Patterns which we use permanently. For example a loop over a list is done by using the … Weiterlesen

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

Use factory methods instead of overloaded constructors

If a class can be created and initialized in different ways or by using different kind of values you may often see overloaded constructors. This is a standard way to implement such an object creation but it has a major … Weiterlesen

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