Eiffel Programming

Welcome to 'Eiffel for Everyone at Wikibooks.

About Eiffel

edit

First developed by Bertrand Meyer, Eiffel has a clean and very readable syntax. Many of the design principles of the language emphasize the readability and maintainability of the code.

Because of its excellent implementation of language features like multiple inheritance and generics (especially constrained generics) it takes less code to express complex ideas in Eiffel than it does in other programming languages. A strong type system with exhaustive static type checking allows programs to scale easily in size, and to evolve in ways that are difficult to achieve with other languages.

Eiffel has been criticized for being a verbose language, and it's easy to get hung up on the verbosity of some of its constructs (like its loop statement). Yet I've found that other languages that are often hyped for their terseness, especially the C family with Java and C++, can be very verbose in declaration and use of complex types.

Guiding Design Principles

edit
  • Everything is an Object
  • Design by Contract
  • Single Entry, Single Exit
  • The Open/Closed Principle
  • Command/Query Separation

Eiffel Features -- What's Unique About the Language

edit
  Contracts and contract inheritance
  Rich set of assertions
  Multiple Inheritance
  Constrained Genericity
  Type-safe agents (also known as closures)
  Void Safety
  SCOOP (Simple Concurrent Object Oriented Programming)

Anatomy of a Class

edit

Parts of a class

edit
   Eiffel Names
    Reserved words
    Notes or indexing
    Name
    Inherit
    create
    features
    more notes
    the end
  Features
    Attributes
    Functions
       The Uniform Access Principle
    Procedures
       Commands vs Queries

Nuts and Bolts

edit
  Implementing Features
  Local Variables
  Creating objects
  Assignment
  Calling features
  Operators
  Expressions
  Copying Objects
  Comparing Objects
  Conditional control
     The if statement
     The inspect statement
  Iteration—looping
  Flow of Control
  Attachment Checking and Locals (e.g. if attached l_foo as al_foo then ... end)

Base Types

edit
  Expanded Types
    INTEGERs of Various Sizes
    REALs
    CHARACTERs
    BOOLEAN
  Reference Types
    ANY
    STRINGs
    DATE
  Containers

Contracts

edit
  What's required
  What's ensured
  Invariants: What is always true (about a class)
  Checks
  Variants and loop contracts

Inheritance

edit
  Why its useful
  How it works
    LSP
  Renaming
  Redefining
  Undefining
  Extending
  Non-conforming inheritance
  Implementation inheritance
  Multiple inheritance
  Inheritance of Contracts

Generics

edit
  With Containers
  With Algorithms
  Constrained Genericity
  Example: Hash tables
  

Tuples

edit
 Uses for tuples
 Returning multiple values from a function
 Named tuples

Agents

edit
 As a way of iterating over containers
 Using agents
 Closed and Open Arguments
 Agent declarations

Libraries

edit

Advanced Topics

edit
 Covariance and Anchored Types
 

Really Advanced Topics

edit
  Memory Management Details
     Garbage Collection Limitations
  Interfacing to Other Languages
  .Net Support
  Low-level Debugging
  

Additional Reading

edit