Abstract Class VS Interface in C#

You can open any C# tutorial and you’ll find some information about abstract classes and interfaces. Most likely, you’ll not find any information about what is the difference between abstract class and interface. This theme was discussed earlier on the Internet several times but I want to consolidate all the most important thoughts regarding the problem of choosing between an abstract class and interface [...]

By |2019-01-11T11:11:11+03:00July 22nd, 2016|Design, .NET, Best Practices, C#, CodeProject|5 Comments

Designing and Implementing API in C#

Nowadays I’m writing my new programming video course. I chose an interesting topic for the next course: “Designing and Implementing API in C#”. How to design API? In this course, you’ll learn how to design and implement types in C# so that the other developers won’t hate you when using one of the types developed by you. It means you are going to learn [...]

By |2016-07-23T15:47:19+03:00July 22nd, 2016|.NET, Best Practices, C#, Design, Refactoring, Video Courses|1 Comment

MVVM: When EventAggregator (aka MessageBus) is an Anti-Pattern

Very often we can see that developers tend to use static message buses for all kind of interactions between objects. For those, who unaware of this pattern I want to recall that this pattern allows organizing loosely coupled communication channel between objects which don’t want (or can’t) to know each other. Let’s have a brief look at how a regular example of using this [...]

By |2019-01-11T11:14:06+03:00June 28th, 2016|Best Practices, CodeProject, Design, WPF, .NET|2 Comments

Objects Equality in C#. Important Facts That You Should Know

Don’t forget that if you want to get my upcoming video courses with 50% discount, then fill the following  form. C# provides many ways to compare objects, not only to compare class instances, but also structures. Actually, there are so many ways, that it requires to put them in order. All those possible options of comparing confuse people in case of misunderstanding them and [...]

By |2016-04-26T16:47:23+03:00April 2nd, 2016|.NET, Best Practices, C#, CodeProject|0 Comments

Money Type as Value Object, or Don’t Rely on Primitive Types!

Primitive Types Obsession Problem Today I’m going to discuss the problem of using primitive types instead of abstractions. This problem was discussed in the blog of Mark Seemann. Read it, if you haven’t read it yet. In this post I’m going to talk about Money type as an abstraction instead of using decimal type for representing money-values. In the last project I’ve been participating [...]

By |2016-04-26T16:35:43+03:00March 17th, 2016|Best Practices, C#, Design, Refactoring, .NET|0 Comments

When Method Is Better Than Property?

That’s a well known question. Actually, I knew the difference between methods and properties long ago. Despite of that, recently I stumbled upon my own incorrect choice between those semantic constructions. That’s why I decided to write this post – in order to solidify the understanding of the difference between property and method. Method vs Property fail in BCL The most notorious fail of [...]

By |2019-01-11T11:17:18+03:00February 27th, 2016|.NET, Best Practices, C#, CodeProject, Design|0 Comments

Make Your Asynchronous C# Code Cancellable

When I was a newcomer I faced with a chunk of long-running code that didn’t support cancellation. I needed to cancel it somehow. Unfortunately, I had no access to that code, so I couldn’t modify it. I was struggling with the requirement to be able to cancel that code. I was thinking about the problem for two days as I remember and I couldn’t believe that it’s actually not possible to cancel random code. Yes, there is the Thread.Abort method presented since .NET 1, but it’s strongly not recommended to use it, because we can’t predict what will happen to the code which is going to be aborted. It’s even almost (or absolutely) impossible to write code which is reliable in case it is aborted by Thread.Abort, because it’s even not guaranteed that your finally-blocks will be executed. One will say that I’m talking about self-evident things, but I’ve heard many times from developers exclamations like, “why we can’t simply use Thread.Abort in order to interrupt that function?” That’s why I decided to write this post, showing how simple it is to write cancellable code.

By |2019-01-11T11:17:39+03:00January 22nd, 2016|.NET, Best Practices, C#, CodeProject, Multithreading|3 Comments

Hidden Dependencies as a Smell

Mark Seemann has written a nice post  “Service Locator violates encapsulation”. The name of the post speaks for itself that it’s about a pattern (anti-pattern) named Service Locator. When a programmer arbitrarily inside the code base calls for the IoC-container to resolve a dependency of an object – he uses a Service Locator anti-pattern. Mark provides the following example: [code language=”csharp”] public class OrderProcessor : [...]

By |2017-09-13T08:48:13+03:00October 27th, 2015|Best Practices, CodeProject, Design, Refactoring, .NET|4 Comments

Handling Errors and Exceptions. Part 2 – Discussion.

The previous blog post received many comments, and this approves that the problem of handling errors\exceptions is palpitating. I thought I’m going to address practical points of errors\exceptions handling in the second part. But I feel I need to address comments of readers firstly. […]

By |2019-01-11T11:17:52+03:00October 2nd, 2015|Best Practices, C#, CodeProject, Design|2 Comments
Go to Top