Vlad's blog

In programming veritas

Posts Tagged ‘Design by contracts

Introduction to Code Contracts

leave a comment »

Starting from .Net 4.0 we have a support of new design by contracts technology called Code Contracts. This post is quick introduction to Code Contract’s basic elements: preconditions, postconditions and invariants with practic examples how to use them.

Suppose we develop an application for online flight booking service. User should go through the following steps in order to book a ticket.

  • Choose a seat from seat map
  • Login into the system
  • Payment

This logic is usually implemented as series of screens that follow each other. The Command pattern can be used in the implementation. Consider ICommand interface which must be implemented by each screen.

Read the rest of this entry »


Written by vsukhachev

July 12, 2011 at 4:15 am

Posted in Development

Tagged with ,