I’ve just read two interesting posts by Steve Sanderson which show how to add these features to the current release of ASP.NET MVC. Really interesting, if you ask me…
November, 2008Archive
If you look closely at your bin folder, you’ll see that besides getting your project’s assembly, you’ll also have another assembly with the your_Assembly_name.Contracts.dll name. This assembly is known as the contract reference assembly and it only has the public “interface” of the types defined on your assembly and their respective contracts. Why do we […]
Code contracts: the missing methods
In the last posts, I’ve been talking extensively about Code Contracts. If you’re a reader of this blog, you know that I’m hooked on it. I’ve just been reviewing the previous posts and I’ve noticed that I didn’t mention the Assert and Assume methods. Both are used for testing state and assumptions on a specific […]
Code Contracts and runtime rewriting
Today we’re going to keep looking at Code Contracts. Until now, I’ve been concentrating essentially in presenting its use and mentioning how great it is to have static analysis (ie, have something that goes through your code at compile time and detects several places which might breaking existing contracts). Today it’s time to take a […]
C# 4.0: named parameters
After several failed tries, I finally managed to configure my home PC so that it runs the Server 2008 image (with the first preview of .NET 4.0) and just with a reasonable enough delay. Ok, since I”m finishing writing a book on C# 3.0 (with my good friend Paulo), I thought that I should start […]
Code Contracts also supports are quantifiers (with several limitations, as we’ll see). This means that you can check a predicate against elements in a collection or interval. You can use the ForAll method for running a predicate over several elements maintained on an collection or interval. The Exists method will let you apply a predicate […]
Code Contracts and compatibility with existing code
2011-01-12 11:31:25
200 000 hits
According to ClustrMaps, I’ve had 200 000 visitors on my blog since I’ve started using their product. Not bad since I never expected to hit the 100 000 mark. I would like to say thanks to Everyone who takes the time to visit this place regularly and contribute with comments on my thoughts about development […]
Adding Code Contracts to your interfaces
[Update: I’ve changed the code so that the contract class implements the interface explicitly. This is required for getting static analysis. One more thing: the first release of the project has a bug and even if you implement the interface explicitly, you won’t get static analysis.] One of the interest things Code Contracts lets you […]
More on Code Contracts: out parameters and field access on preconditions
In this post we’ll keep looking at how Code Contracts can really help you improve your code. Today, we’ll see how one can use fields and out parameters in contracts. Lets start with fields. Ok, the title is a little misleading…you can use fields in your contract. But what happens when you need to define […]
What’s new in the BCL 4.0
I’ve just found an interesting post with some of the new stuff we’ll have on the next version of the BCL. I’m already testing Code Contracts, but it seems like there’s still a long way to go…
Code Contracts: don’t use the overloads that receive a string
In my first post about Code Contracts I’ve mentioned that in my machine static analysis wasn’t picking up those evident scenarios where the code was breaking the predefined contracts. Today I’ve got the confirmation on the PEX forum (which, btw, is the place where you should post your questions regarding this framework while we don’t […]
More on code contracts: checking return values and old values
Today I’ll keep writing about the new Code Contracts framework and we’ll see how we can use the write contracts that validate method return values and “old” values. Lets start with method return values… As you might expect, you’re able to refer to return values on your postconditions. To show you the kind of thing […]
C#, LINQ and running several methods over instances of a collection
One of the things that I’ve needed to do in the past is filter a sequence of items and then execute a specific method over each of those filtered instances. The Enumerable class introduces several methods, but it doesn’t have any that lets me pass an Action<T> that is invoked over each instance of an […]
Another very smart guy :)
Not technical, so move on if you don’t like soccer…just watch how this guy reacts after receiving the yellow card :,,)
More on Code Contracts
Yesterday I was really excited after finding out that we’ll finally have a library for performing Design By Contract verifications on our code. Ok, the runtime validations could already be simulated by writing some code (I’ve already written several helpers classes in my current applications), but the truth is that the Code Contracts library adds […]
The new MacBook
I’m pissed! I waited several months before buying a notebook. After having bought the Toshiba, Apple releases the new MacBook which is amazing…Unfortunately, I can’t buy another notebook and that makes me feel really bad…oh well, what can I say?
Book review: More Joel on Software….
2011-01-12 11:30:22