mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2025-12-06 14:52:03 +01:00
Author:halw
Date:2008-10-14T22:21:18.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@82 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
@@ -7,17 +7,17 @@ When discovering any approach to software construction, however ambitious its go
|
||||
You write a class <code> HELLO </code> with a single procedure, say <code> make </code>, also serving as creation procedure. If you like short texts, here is a minimal version:
|
||||
<code>
|
||||
class
|
||||
HELLO
|
||||
HELLO
|
||||
|
||||
create
|
||||
make
|
||||
make
|
||||
|
||||
feature
|
||||
|
||||
make is
|
||||
do
|
||||
print ("Hello World%N")
|
||||
end
|
||||
make
|
||||
do
|
||||
print ("Hello World%N")
|
||||
end
|
||||
|
||||
end
|
||||
</code>
|
||||
@@ -25,23 +25,23 @@ end
|
||||
In practice, however, the Eiffel style rules suggest a better documented version:
|
||||
<code>
|
||||
indexing
|
||||
description: "Root for trivial system printing a message"
|
||||
author: "Elizabeth W. Brown"
|
||||
description: "Root for trivial system printing a message"
|
||||
author: "Elizabeth W. Brown"
|
||||
|
||||
class
|
||||
HELLO
|
||||
HELLO
|
||||
|
||||
create
|
||||
make
|
||||
make
|
||||
|
||||
feature
|
||||
|
||||
make is
|
||||
-- Print a simple message.
|
||||
do
|
||||
io.put_string ("Hello World")
|
||||
io.put_new_line
|
||||
end
|
||||
make
|
||||
-- Print a simple message.
|
||||
do
|
||||
io.put_string ("Hello World")
|
||||
io.put_new_line
|
||||
end
|
||||
|
||||
end -- class HELLO
|
||||
</code>
|
||||
@@ -56,7 +56,7 @@ The name of the class is <code> HELLO </code>. Any class may contain "features";
|
||||
|
||||
The definition of <code> make </code> appears in a <code> feature </code> clause. There may be any number of such clauses (to separate features into logical categories), and each may contain any number of feature declarations. Here we have only one.
|
||||
|
||||
The line starting with <code> -- </code> (two hyphen signs) is a comment; more precisely it is a "header comment", which style rules invite software developers to write for every such feature, just after the <code> is </code>. As will be seen in [[8 Design by Contract (tm), Assertions and Exceptions|"The contract form of a class", page 44]] , the tools of EiffelStudio know about this convention and use it to include the header comment in the automatically generated class documentation.
|
||||
The line starting with <code> -- </code> (two hyphen signs) is a comment; more precisely it is a "header comment", which style rules invite software developers to write for every such feature, just after the feature is named. As will be seen in [[8 Design by Contract (tm), Assertions and Exceptions#The_contract_form_of_a_class|"The contract form of a class"]], the tools of EiffelStudio know about this convention and use it to include the header comment in the automatically generated class documentation.
|
||||
|
||||
The body of the feature is introduced by the <code> do </code> keyword and terminated by <code> end </code>. It consists of two output instructions. They both use <code> io </code>, a generally available reference to an object that provides access to standard input and output mechanisms; the notation <code> io </code> . <code> f </code>, for some feature <code> f </code> of the corresponding library class ( <code> STD_FILES </code>), means "apply <code> f </code> to <code> io </code>". Here we use two such features:
|
||||
* <code> put_string </code> outputs a string, passed as argument, here <code> "Hello World" </code>.
|
||||
|
||||
Reference in New Issue
Block a user