quote:Original post by silvren
to Wayfarer:
But if you use the first alternative, do you use capitals or something like that?
// RUNGE-KUTTA
...
// nested comment
or maybe
// R U N G E - K U T T A
...
// nested comment
or even
// ------Runge-kutta
...
// nested comment
I agree with Magmai. I''m especially pre-disposed to writing many small functions since I''m a Java convert and calling out into functions in Java is actually more efficient than loading one big one on to the stack (go figure).
Here is a little explanation of the Wayfarer coding:
So I''ve got some prliminary ideas jotted down, I''ve got Dia (which rules) open in the background with some OO diagrams of whatever I happen to be making. For me, coding a function involved first writing a java-style doc-comment (which is similar to what the AP posted, but a little more structured). My description is an english-language version of exactly what the method does and what effects it has on the members of that object. Then, when I open up the .cpp file to write the body of the method, I watch for when I start to do things like you mentioned, when certain groups of lines begin to take on their own personality seperate from the function their in (like your example). It''s this point in time when the .h file is opened back up and another function is added to the interface.
Of course when and how you do this is generally a matter of taste, writing small, modular functions clears up the readability of code enormously.
As for comment style:
/** Method Name * Description * Preconditions * Postcontidions * @param param1 the first parameter * @param param2 the second parameter * @return return value */ int CWhatever::method_name (int param1, int param2) { return param1 + param2; }
I generally try to avoid things like massive indentations, dashes, all-caps, and putting spaces between all the letters of a comment I want to stand out. Alhtough it makes it easier to spot, it slows down the speed I type and genrally just becomes a hassle of a convention to stick with.
"If consquences dictate our course of action, it doesn''t matter what''s right, it''s only wrong if you get caught."
- Tool