Difference between revisions of "Eiffel Coding Standard"
Peter gummer  (Talk | contribs)  m  | 
				|||
| (4 intermediate revisions by one other user not shown) | |||
| Line 5: | Line 5: | ||
:* '''inherit''' and parent clauses  | :* '''inherit''' and parent clauses  | ||
* Do not use assertion clauses without tag names.  | * Do not use assertion clauses without tag names.  | ||
| + | |||
| + | A sample of proper formatting of code:  | ||
| + | <e>note  | ||
| + |     description: "Descr...."  | ||
| + |     date: "$date: $"  | ||
| + | |||
| + | class A  | ||
| + | |||
| + | inherit  | ||
| + |     B  | ||
| + |        rename  | ||
| + |            f as g  | ||
| + |        end  | ||
| + | |||
| + | create  | ||
| + |     make  | ||
| + | |||
| + | feature {NONE} -- Initialization  | ||
| + | |||
| + |     make (a: INTEGER)  | ||
| + |             -- Initialize Current with `a'.  | ||
| + |         do  | ||
| + |         end  | ||
| + | |||
| + | invariant  | ||
| + |     a_positive: a > 0  | ||
| + | |||
| + | end</e>  | ||
==Style==  | ==Style==  | ||
| Line 14: | Line 42: | ||
else  | else  | ||
     ...  |      ...  | ||
| − | end  | + | end</e>  | 
| − | </e>  | + | |
| + | If expressions are very long, break them on conjunctions as in:  | ||
| + | <e>if  | ||
| + |     expr1 or else  | ||
| + |     expr2  | ||
| + | then  | ||
| + |     ...  | ||
| + | end</e>  | ||
| + | |||
| + | * Loop instructions:  | ||
| + | <e>from  | ||
| + |     ...  | ||
| + | until  | ||
| + |     ...  | ||
| + | loop  | ||
| + |     ...  | ||
| + | end</e>  | ||
| + | |||
| + | * Inspect instructions:  | ||
| + | <e>inspect expr  | ||
| + | when val1 then ....  | ||
| + | else  | ||
| + |     ...  | ||
| + | end</e>  | ||
| + | |||
| + | or  | ||
| + | |||
| + | <e>inspect  | ||
| + |     expr  | ||
| + | when val1 then  | ||
| + |     ...  | ||
| + | else  | ||
| + |     ...  | ||
| + | end</e>  | ||
| + | |||
| + | * For punctuation, we always have a space before '''(''' and a space after ''')''', ''',''', ''':''', or ''';''':  | ||
| + | <e>require  | ||
| + |    a_tag: query (a, b, c) or other_query (c, d)  | ||
| + | local  | ||
| + |    i: INTEGER; j: INTEGER</e>  | ||
Latest revision as of 23:11, 3 August 2013
Language consideration
- Do not put a blank line between
 
- create and creation instructions
 - inherit and parent clauses
 
- Do not use assertion clauses without tag names.
 
A sample of proper formatting of code:
note
    description: "Descr...."
    date: "$date: $"
 
class A
 
inherit
    B
       rename
           f as g
       end
 
create
    make
 
feature {NONE} -- Initialization
 
    make (a: INTEGER)
            -- Initialize Current with `a'.
        do
        end
 
invariant
    a_positive: a > 0
 
end
Style
- If instructions:
 
if expr1 then ... elseif expr2 then ... else ... end
If expressions are very long, break them on conjunctions as in:
if expr1 or else expr2 then ... end
- Loop instructions:
 
from ... until ... loop ... end
- Inspect instructions:
 
inspect expr when val1 then .... else ... end
or
inspect expr when val1 then ... else ... end
- For punctuation, we always have a space before ( and a space after ), ,, :, or ;:
 
require a_tag: query (a, b, c) or other_query (c, d) local i: INTEGER; j: INTEGER

