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
47 Long class documentation.
50 /** short description.
58 short memo. long doco of member()
66 Unfortunately most of the code isn't really documented that good.
71 A lot of classes in LilyPond start with 'P', this is to distinguish
72 certain parts of LilyPond: the P stands for Printer, and the P-classes
73 are supposed to be more lowlevel than the others. Example:
75 Staff uses PStaff, PScore and PCol to do the typesetting of
76 symbols. Staff is the "brains" for PStaff
78 NB: in PCursor (which is part of the library) P stands for PointerCursor
85 ///check that *this satisfies its invariants, abort if not.
88 /// print *this (and substructures) to debugging log
92 protected member. Usually invoked by non-virtual A_virtual_func()
94 virtual do_A_virtual_func()
96 /**add some data to *this.
97 Presence of these methods usually imply that it is not feasible to this
102 /// replace some data of *this
105 =head1 HUNGARIAN NOTATION NAMING CONVENTION
107 Proposed is a naming convention derived from the so-called I<Hungarian
112 The Hungarian Notation was conceived by
113 or at least got its name from,
114 the hungarian programmer x.
115 It is a naming convention with the aim
116 to make code more readable (for fellow programmers)
117 and more accessible for programmers
118 that are new to a project.
120 The essence of the Hungarian Notation
121 is that every identifier has a part
122 which identifies its type
123 (for functions this is the result type).
124 This is particularly useful in object oriented programming,
125 where a particular object implies a specific interface
126 (a set of member functions, perhaps some redefined operators),
127 and for accounting heap allocated memory pointers and links.
131 Another fun quote from Microsoft Secrets:
134 The Hungarian naming convention gives developers the ability
135 to read other people's code relatively easily, with a minmum
136 number of comments in the source code. Jon De Vann estimated
137 that only about 1 percent of all lines in the Excel product
138 code consist of comments, but the code is still very
139 understandable due to the use of Hungarian: "if you look at
140 our source code, you also notice very few comments. Hungarian
141 gives us the ability to go in and read code..."
144 Wow! If you use Hungarian you don't have to document your software!
145 Just think of the hours I have wasted documenting while this "silver bullet"
146 existed. I feel so stupid and ashamed!
153 more keystrokes (disk space!)
156 it looks silly C<get_slu_p()>
159 it looks like code from micro suckers
162 (which) might scare away some (otherwise good?)
163 progammers, or make you a paria in the free
170 not very useful if not used consistently
173 usefullness in I<very large>
174 (but how many classes is very large?)
186 learn about cut and paste / use emacs or vi
187 or lean to type using ten fingers
190 Use emacs dabbrev-expand, with dabbrev-case-fold-search set to nil.
193 use no, or pick less silly, abbrvs.
196 use non-ambiguous postfixes C<identifier_name_type_modifier[_modifier]>
199 Macros, C<enum>s and C<const>s are all uppercase,
200 with the parts of the names separated by underscores.
225 Zero terminated c string
232 =head2 User defined types
239 Slur* slur_p = new Slur;
243 The following types modify the meaning of the prefix.
244 These are precede the prefixes:
258 temporary pointer to object (link)
261 pointer to newed object
271 Variable loop: an integer
274 Temporary variable: an unsigned integer
277 Variable Test: a character
279 =item C<firstName_str>
280 Variable first_name: a String class object
282 =item C<first_name_ch_a>
283 Variable first_name: a C<char> array
286 Variable Loop: an C<Int*> that you must delete
289 Variable Loop: an C<Int*> that you must not delete