This is the third article in a series about exceptions: BasicsTypes and filteringWhere to put catch blocks and handle exceptionsFinishing up Where your catch blocks are and where exceptions are dealt with matters - probably best to avoid sticking a pin into your code randomly to choose the spot.Image credit The location of catch blocks … Continue reading Exceptions 3: Where to put catch blocks and handle exceptions
Category: C#
Exceptions 2: Types and filtering
This is the second article in a series about exceptions: BasicsTypes and filteringWhere to put catch blocks and handle exceptionsFinishing up You can filter which exceptions a given catch block deals with.Image credit. Type hierarchy for exceptions As I said in the previous article, an exception is an object with a particular type. Often, in … Continue reading Exceptions 2: Types and filtering
Exceptions 1: Basics
This is the first of two things requested by Jesper. Please visit his blog for wisdom about testing, business strategy and things like that. I’m not always available for weddings and bar mitzvahs, but if anyone else has requests or suggestions for the blog, please let me know via the Contact page. This started off … Continue reading Exceptions 1: Basics
Finite state machines
This is the second article in a series about some classic computer science: Regular expressionsFinite state machinesComparing regular expressions and finite state machines Finite state machines are a way of checking that a series of inputs is valid, potentially doing some actions while you’re doing this checking. They’re not something I use all that often, … Continue reading Finite state machines
Recursion and iteration – blurring the lines
This article is part of a series on recursion and iteration Introduction to iterationIntroduction to recursionMutual recursion and tail recursionBlurring the linesLoop unrolling In this article I will look at how the lines between iteration and recursion can get a bit blurry. This breaks down into three areas: Iteration = fast, recursion = slow isn't … Continue reading Recursion and iteration – blurring the lines
Recursion and iteration – an introduction to iteration
This is the first of a series of articles about recursion and iteration Introduction to iterationIntroduction to recursionMutual recursion and tail recursionBlurring the linesLoop unrolling Recursion and iteration are both techniques for doing some work (or similar work) repeatedly, so that you can solve a bigger problem. This could be things like summing all the … Continue reading Recursion and iteration – an introduction to iteration
The cost of flexibility
Flexibility in software design is often seen as a good thing, but it can come at a cost. This isn’t surprising, because software engineering is a kind of engineering, and engineering involves making trade-offs among several good things. For instance, there is no “best” car, just the best car for a given situation, with a … Continue reading The cost of flexibility
Covariance and contravariance, part 3: Covariance in interfaces
This article is the third in a series on covariance and contravariance: Covariance in arraysContravariance in interfacesCovariance in interfaces In the previous article I showed how an interface could be contravariant, meaning it is expecting a smaller type for something you pass it. In this article I will show how an interface can be covariant, … Continue reading Covariance and contravariance, part 3: Covariance in interfaces
Captured variables
This article is about captured variables in C#. In case you've not come across them before, they're where some code appears to capture and drag with it a variable declared outside the code, such that the code can continue using the variable long after it appears that this should be possible. They’re not something I … Continue reading Captured variables
Covariance and contravariance, part 2: Contravariance in interfaces
This is part two in a series about variance – contravariance and covariance. Arrays and listsContravariance in interfacesCovariance in interfaces In the previous article I introduced the concepts of variance and type size. I also gave arrays as an example of covariance. In this article I’ll give an example of contravariance, and go into more … Continue reading Covariance and contravariance, part 2: Contravariance in interfaces