Class Layout PreviousNext

Indentations

Indentations from the left margin should be made up of tabs. Please to not use space characters as mixing spaces and tabs gives ugly results when people use different sizes for tabs. Throughout this documentation tabs will be represented by an underscore followed by three spaces in order to make them clearly visible on the page. Here is a example:

_   set_foo (a_foo: like foo)
_   _   _   -- Set `foo' to `a_foo'.
_   _   require
_   _   _   a_foo_not_void: a_foo /= Void
_   _   do
_   _   _   foo := a_foo
_   _   ensure
_   _   _   foo_set: foo = a_foo
_   _   end

Some text editors provide a means similar to the one described above in order to make tabs visible. It is recommended that you enable such facility if you use one of those editors.

General Layout

Here is how a class text should look like:

note

_   description:

_   _   "Short description of the class"

_   library:    "Gobo Eiffel Lexical Library"
_   copyright:  "Copyright (c) 2000-2016, Eric Bezault and others"
_   license:    "MIT License"
_   date:       "$Date$"
_   revision:   "$Revision$"

class BAR [G -> TOTO]

inherit

_   BAZ
_   _   rename
_   _   _   oof as foo,
_   _   _   f as g
_   _   redefine
_   _   _   foo, bar
_   _   end

create

_   make, make_from_string

feature {NONE} -- Initialization

_   make (a_foo: FOO)
_   _   _   -- Create a new bar.
_   _   require
_   _   _   a_foo_not_void: a_foo /= Void
_   _   do
_   _   _   set_foo (a_foo)
_   _   ensure
_   _   _   foo_set: foo = a_foo
_   _   end

_   make_from_string (a_string: STRING)
_   _   _   -- Create a new bar from `a_string'.
_   _   require
_   _   _   a_string_not_void: a_string /= Void
_   _   do
_   _   _   create foo.make_from_string (a_string)
_   _   end

feature -- Access

_   foo: FOO
_   _   _   -- Foo

feature -- Setting

_   set_foo (a_foo: like foo)
_   _   _   -- Set `foo' to `a_foo'.
_   _   require
_   _   _   a_foo_not_void: a_foo /= Void
_   _   do
_   _   _   foo := a_foo		
_   _   ensure
_   _   _   foo_set: foo = a_foo
_   _   end

invariant

_   foo_not_void: foo /= Void

end

Apart from the indentation, please notice that there is one and only one empty line between each top-level construct of the class, and also between features in feature clauses.

(Borrow the guidelines from OOSC2 section 26.5 page 891. Note that contrary to the guidelines in OOSC2, the recommended layout for Gobo Eiffel classes in to put the class name on the same line as the class keyword — see class BAR above.)


Copyright © 2001-2016, Eric Bezault
mailto:ericb@gobosoft.com
http://www.gobosoft.com
Last Updated: 22 December 2016
HomeTocPreviousNext