RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Eiffel for .NET: An Introduction

Eiffel Software Inc.'s Eiffel for .NET is now available as part of ESI's EiffelStudio. Eiffel for .NET combines the power of two object technology variants: Eiffel (including Design by Contract, multiple inheritance, genericity and seamlessness of software development) and .NET (including language interoperability, Web services and other advanced facilities).

his article describes the goals and scope of the Eiffel language and explains how Eiffel for .NET can interoperate with other .NET languages. The article also demonstrates using Eiffel for .NET to build graphical user interfaces, using Windows Forms, to access databases and develop Web services.

The Fundamentals of Eiffel for .NET
The .NET platform contains some innovative development concepts including language interoperability and extensive support for development of Web services. The .NET platform also provides a rich collection of software facilities (security, component-based development, versioning, memory management, etc.), which make it a powerful development tool in the field of computing. With all of this innovation, Eiffel Software, Inc. (ESI) decided to give Eiffel programmers the chance to benefit from all of these innovations while also giving .NET users a chance to benefit from the power of Eiffel. This effort resulted in Eiffel for .NET, bringing Design by Contract, multiple inheritance and genericity to the .NET world.

Eiffel was ported to the .NET environment from the very beginning of .NET. The first version was called Eiffel#. This version is now obsolete being replaced by Eiffel for .NET.

Fast Facts
Eiffel for .NET provides a best-of-breed solution for software development on the .NET Framework. This article explains the fundamentals of Eiffel for .NET and gives concrete examples for programmers.

Design by Contract
Like Eiffel, Eiffel for .NET directly enforces Design by Contract through constructs such as class invariants, routine preconditions and postconditions, check instructions and loop invariants. The idea of programming with contracts (inspired by commercial relationships and business contracts) is to formally express the rights and obligations binding a client and a supplier, which addresses the following issues:

  • Correctness: Contracts help build software right in the first place.
  • Documentation: Contracts make it possible to automatically extract documentation from the code itself.
  • Debugging and testing: Run time monitoring of contracts facilitates detection of errors in the software text.
  • Inheritance control: The principles of Design by Contract provide a coherent approach to inheritance, limiting the extent to which new routine definitions can affect the original semantics (pre-conditions can only be weakened while post-conditions can only be strengthened).
  • Management: Contracts help onlookers to better understand the global meaning of a program without looking at the core implementation.
A recent report by the Software Engineering Institute highlights the usefulness of contracts, confirming that the use of contracts in building components is a key factor in improving software composability and reusability.

Eiffel for .NET is the sole language on the .NET Framework to support contracts natively. Some other languages do have contracts, but not as a language construct: they provide add-ons to support it. The weaknesses of such approaches mostly deal with dynamic contract checking and contract inheritance (especially multiple inheritance).

In the specific context of .NET, ESI has developed a Contract Wizard. The Contract Wizard gives developers the ability to add contracts to the classes and routines of an existing .NET assembly. The Contract Wizard builds a "proxy" assembly, which has the contracts, but calls the original assembly code. This solution takes advantage of the flexibility of the .NET component model, in particular the notion of metadata (interface information that every assembly includes).

This approach provides a way to "contract" a component a posteriori, which should help understand the library better, improve its documentation and make it safer to use. It also benefits from its internal use of Eiffelas: an intermediate language to add contracts—providing inheritance of assertions (contrary to most "contract tools" for non-Eiffel languages, such as iContract and Jcontract in Java).

However, the right time to put in the contracts, in good library development, is during design. A posteriori addition of contracts can never be as efficient as a native implementation with contracts. For example, one cannot avoid the speed penalty of looking up the assembly metadata. It also takes time for users to enter assertions after the fact, which can become prohibitive when dealing with large-scale software development. Finally, a posteriori contraction is helpless regarding the design of the existing libraries: the contracted component is just an "Eiffel mapping" of its .NET counterpart. For example, components developed with a language that does not support contracts often use a very "defensive" style of programming (checking the routine requirements with If statements), which can yield rather inefficient software, especially when the software is big and such checks numerous. Eiffel for .NET users simply rely on assertions, leading to a lighter and more efficient programming style.

Seamlessness of Software Development
The "natural" environment to develop your Eiffel applications is EiffelStudio, although you will see later that this is not the only choice.

Figure 1: EiffelStudio: The Eiffel development environment.
One of the strong points of Eiffel is that it covers the entire software lifecycle. EiffelStudio (see Figure 1) enables you to put this method into practice: you can use it from analysis and design to implementation and maintenance with complete seamlessness between each step of development. In particular, EiffelStudio provides an integrated Diagram Tool to help you construct and read complex inheritance structures. The Diagram Tool would not be anything special by itself (drawing inheritance relationships could be done with UML as well); its real power comes from its interaction with the other facilities of the EiffelStudio. These capabilities make EiffelStudio an innovative and convenient tool for large-scale software construction. The Diagram Tool is fully "clickable," meaning that the user can navigate between classes—including class texts—easily and intuitively, as if he or she was following hyperlinks on the Web. It also provides complete reversibility between the text and graphical views of your system, updating the software text—after compilation—whenever you change the graphics, and conversely.

The latest release of EiffelStudio was reviewed in Software Development Magazine in May 2002 as an "excellent environment for developing object-oriented applications with a well-tested, elegant OO programming language."

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date