Blog Posts

Clash of Styles, Part #5 – Double Dispatch, or When to Abandon OOP

OOP is established to the point that we sometimes follow absurdly complicated “idiomatic” patterns(tricks). One example is the Double Dispatch technique, which is a quite puzzling chain of polymorphic calls. Let’s see it in action and compare it to a quite elegant Functional alternative.

Continue Reading

Clash of Styles, Part #4 – Adding Support for Rational Numbers with FP

FP or OOP is not a binary choice. You can have a healthy mix of the two in your program. Whatever paradigm you select to be central to your design, there will be cases when the other style fits better. Let’s start exploring this in Part #4 of the Clash of Styles series.

Continue Reading

Clash of Styles, Part #3 – Extensibility via OOP and FP

The choice between FP and OOP can directly affect the maintainability characteristics of your program. What is “easy” to add in OOP is “hard” in FP and vice versa. How can that be presented in terms of the Open-Closed Principle? What are some practical examples? Explore those topics in Part #3 of the Clash of Styles series.

Continue Reading

Clash of Styles, Part #2 – Operations Matrix via FP

How do we "interpret" our requirements with a Functional Programming mindset? How does it encourage us to decompose our program in terms of Operations? How is that precisely the opposite of the OOP perspective? Learn about it in the second part of the "Clash of Styles" series. Examples in C# and F#

Continue Reading

Don’t Help Your Clients to Deadlock

If you’re not careful what and when you invoke from within a critical section, you may cause a deadlock. Everything may seem correct from yours’ and your clients’ perspective, but out of a sudden, the program may go to sleep forever. In this article, I’ll demonstrate some scenarios when this can happen and what you can do(or even should do) to mitigate the risk. But first, let’s do a quick refresher on the lock statement in C# and why we

Continue Reading

A Practical Intro to Covariance and Contravariance in C#

When defining a generic interface, have you received a hint from Resharper like “The type parameter T could be declared as covariant” (or “contravariant”)? If so, have you then blindly applied the proposed refactoring which decorates your generic parameter with the in or out keyword? Like so: I know I’ve done this a few times before deciding to dig deeper into what these terms actually mean and how they affect my type’s behavior. Type variance is one of the topics

Continue Reading

Site Footer