跳轉到內容

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
  

補充閱讀

[編輯 | 編輯原始碼]
華夏公益教科書