3 CodingStyle - standards while programming for LilyPond
7 Please use these standards while doing programming for LilyPond
9 Functions and methods do not return errorcodes, but use assert for
17 (add-hook 'c-mode-hook
18 '(lambda ()(setq c-basic-offset 4)))
21 (add-hook 'c++-mode-hook
22 '(lambda() (c-set-style "Stroustrup")
27 =head2 CLASSES and TYPES:
30 AClass_name (for Abbreviation_class_name)
35 Type Class::member_type_
37 the C<type> is a Hungarian notation postfix for $C<Type>$. See below
42 The source is commented in the DOC++ style. Check out doc++ at
43 http://www.zib.de/Visual/software/doc++/index.html
46 C style comments for multiline comments.
53 Long class documentation.
66 short memo. long doco of member()
67 @param description of arguments
70 Rettype member(Argtype);
76 Unfortunately most of the code isn't really documented that good.
81 A lot of classes in LilyPond start with 'P', this is to distinguish
82 certain parts of LilyPond: the P stands for Printer, and the P-classes
83 are supposed to be more lowlevel than the others. Example:
85 Staff uses PStaff, PScore and PCol to do the typesetting of
86 symbols. Staff is the "brains" for PStaff
88 NB: in PCursor (which is part of the library) P stands for PointerCursor
95 ///check that *this satisfies its invariants, abort if not.
98 /// print *this (and substructures) to debugging log
102 protected member. Usually invoked by non-virtual XXXX()
106 /**add some data to *this.
107 Presence of these methods usually imply that it is not feasible to this
112 /// replace some data of *this
115 =head1 HUNGARIAN NOTATION NAMING CONVENTION
117 Proposed is a naming convention derived from the so-called I<Hungarian
122 The Hungarian Notation was conceived by or at least got its name from,
123 the hungarian programmer Charles Simonyi. It is a naming convention
124 with the aim to make code more readable (for fellow programmers), and
125 more accessible for programmers that are new to a project.
127 The essence of the Hungarian Notation is that every identifier has a
128 part which identifies its type (for functions this is the result
129 type). This is particularly useful in object oriented programming,
130 where a particular object implies a specific interface (a set of
131 member functions, perhaps some redefined operators), and for
132 accounting heap allocated memory pointers and links.
136 Another fun quote from Microsoft Secrets:
139 The Hungarian naming convention gives developers the ability
140 to read other people's code relatively easily, with a minmum
141 number of comments in the source code. Jon De Vann estimated
142 that only about 1 percent of all lines in the Excel product
143 code consist of comments, but the code is still very
144 understandable due to the use of Hungarian: "if you look at
145 our source code, you also notice very few comments. Hungarian
146 gives us the ability to go in and read code..."
149 Wow! If you use Hungarian you don't have to document your software!
150 Just think of the hours I have wasted documenting while this "silver bullet"
151 existed. I feel so stupid and ashamed!
158 more keystrokes (disk space!)
161 it looks silly C<get_slu_p()>
164 it looks like code from micro suckers
167 (which) might scare away some (otherwise good?)
168 progammers, or make you a paria in the free
175 not very useful if not used consistently
178 usefullness in I<very large>
179 (but how many classes is very large?)
191 learn about cut and paste / use emacs or vi
192 or lean to type using ten fingers
195 Use emacs dabbrev-expand, with dabbrev-case-fold-search set to nil.
198 use no, or pick less silly, abbrvs.
201 use non-ambiguous postfixes C<identifier_name_type_modifier[_modifier]>
204 Macros, C<enum>s and C<const>s are all uppercase,
205 with the parts of the names separated by underscores.
212 unsigned char. (The postfix _by is ambiguous)
233 Zero terminated c string
240 =head2 User defined types
247 Slur* slur_p = new Slur;
251 The following types modify the meaning of the prefix.
252 These are precede the prefixes:
266 temporary pointer to object (link)
269 pointer to newed object
279 Variable loop: an integer
282 Temporary variable: an unsigned integer
285 Variable test: a character
287 =item C<first_name_str>
288 Variable first_name: a String class object
290 =item C<last_name_ch_a>
291 Variable last_name: a C<char> array
294 Variable foo: an C<Int*> that you must delete
297 Variable bar: an C<Int*> that you must not delete