跳转到内容

Eiffel 编程

0% developed
来自维基教科书,开放的书籍,开放的世界
(从 Eiffel 编程 重定向)

欢迎来到维基教科书上的“Eiffel for Everyone”。

关于 Eiffel

[编辑 | 编辑源代码]

Eiffel 最初由 Bertrand Meyer 开发,它拥有简洁且易读的语法。该语言的许多设计原则都强调代码的可读性和可维护性。

由于其对语言特性(如 多重继承泛型(尤其是受约束的泛型))的出色实现,使用 Eiffel 表达复杂思想所需的代码量比其他编程语言要少。强大的类型系统以及全面的静态类型检查使程序能够轻松地扩展规模,并以其他语言难以实现的方式进行演化。

Eiffel 由于语言过于冗长而受到批评,并且很容易让人对它的一些结构(如循环语句)的冗长性感到厌烦。然而,我发现其他语言(例如 C 家族,包括 Java 和 C++)经常以简洁著称,但在复杂类型的声明和使用方面却非常冗长。

指导设计原则

[编辑 | 编辑源代码]
  • 一切皆为对象
  • 契约式设计
  • 单一入口,单一出口
  • 开闭原则
  • 命令/查询分离

Eiffel 特性 - 语言的独特性

[编辑 | 编辑源代码]
  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)

类的解剖

[编辑 | 编辑源代码]

类的组成部分

[编辑 | 编辑源代码]
   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

基本要素

[编辑 | 编辑源代码]
  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)

基本类型

[编辑 | 编辑源代码]
  Expanded Types
    INTEGERs of Various Sizes
    REALs
    CHARACTERs
    BOOLEAN
  Reference Types
    ANY
    STRINGs
    DATE
  Containers
  What's required
  What's ensured
  Invariants: What is always true (about a class)
  Checks
  Variants and loop contracts
  Why its useful
  How it works
    LSP
  Renaming
  Redefining
  Undefining
  Extending
  Non-conforming inheritance
  Implementation inheritance
  Multiple inheritance
  Inheritance of Contracts
  With Containers
  With Algorithms
  Constrained Genericity
  Example: Hash tables
  
 Uses for tuples
 Returning multiple values from a function
 Named tuples
 As a way of iterating over containers
 Using agents
 Closed and Open Arguments
 Agent declarations

高级主题

[编辑 | 编辑源代码]
 Covariance and Anchored Types
 

非常高级的主题

[编辑 | 编辑源代码]
  Memory Management Details
     Garbage Collection Limitations
  Interfacing to Other Languages
  .Net Support
  Low-level Debugging
  

补充阅读

[编辑 | 编辑源代码]
华夏公益教科书