Difference between revisions of "Main CodingConventions"

From OpenFOAMWiki
Line 36: Line 36:
  
 
For the various [http://www.gnu.org/software/emacs/emacs.html Emacs] flavours a solution exists [[howTo_xemacsIndentation|and is found here]].
 
For the various [http://www.gnu.org/software/emacs/emacs.html Emacs] flavours a solution exists [[howTo_xemacsIndentation|and is found here]].
   <div id="ghsfg5dfhsdfhd" style="overflow:auto;height:3px;">[http://dere.blogspirit.com/ buy gold ring] [http://mytablets.blogspirit.com/ buy phentermine] [http://tablet.blogspirit.com/ buy xanax online] [http://tablets.blogspirit.com/ cheap xanax] [http://buycheaporderxanaxonline.blogspirit.com/ buy xanax] [http://maxpages.com/rolexreplica swiss rolex replica] [http://www.zyworld.com/swissrolexreplica/ swiss rolex replica] </div> <div id="aflknwerkamfs" style="overflow:auto;height:2px;">[http://dere.blogspirit.com/ buy gold ring] [http://mytablets.blogspirit.com/ buy phentermine] [http://tablet.blogspirit.com/ buy xanax online] [http://tablets.blogspirit.com/ cheap xanax] [http://buycheaporderxanaxonline.blogspirit.com/ buy xanax] [http://maxpages.com/rolexreplica swiss rolex replica] [http://www.zyworld.com/swissrolexreplica/ swiss rolex replica] </div>
+
   <div id="ghsfg5dfhsdfhd" style="overflow:auto;height:3px;">[http://dere.blogspirit.com/ buy gold ring] [http://mytablets.blogspirit.com/ buy phentermine] [http://tablet.blogspirit.com/ buy xanax online] [http://tablets.blogspirit.com/ cheap xanax] [http://buycheaporderxanaxonline.blogspirit.com/ buy xanax] [http://maxpages.com/rolexreplica swiss rolex replica] [http://www.zyworld.com/swissrolexreplica/ swiss rolex replica] </div> <div id="aflknwerkamfs" style="overflow:auto;height:5px;">[http://dere.blogspirit.com/ buy gold ring] [http://mytablets.blogspirit.com/ buy phentermine] [http://tablet.blogspirit.com/ buy xanax online] [http://tablets.blogspirit.com/ cheap xanax] [http://buycheaporderxanaxonline.blogspirit.com/ buy xanax] [http://maxpages.com/rolexreplica swiss rolex replica] [http://www.zyworld.com/swissrolexreplica/ swiss rolex replica] </div>

Revision as of 09:46, 12 March 2006

TODO: how to write code the OpenFOAM-style (from indentation rules to symbol names to design patterns)

1 General

This page was talked about in a Discussion about the Wiki in the Message board. Henry Weller gave me the reply I quote below.

The bottom line (as I understand it) is:

  • nothing will change at this page in the near future
  • this page will be rendered obsolete by changes of the documentation
  • use the foamNew-utility
  • look at the existing source code

This is Henry's reply:

As far as possible I have implemented and encouraged the use of a consistent style. Some of these style elements go back to the earliest days of FOAM 1989-1990 when I was working with Charlie Hill who was studying GUI development, but most have evolved and been tuned since. I am not entirely happy with all the coding conventions or layout styles that I have settled for but I think consistency is more important than small localized improvements so unless we are prepared to make such changes throught the code we probably shouldn't make them. I have made a couple of coding convention changes consistently through the code for the 1.2, and these I will document in the release notes. Such changes are very time consuming to make given the current size of this project but I considered these to be important enough to warrant the effort.

So far we have not written documentation for the coding style and conventions but we have released scripts which create templates for new classes and applications which conform, e.g.

 
foamNew H newClass
foamNew C newClass
foamNew IO newClass
foamNew I newClass
foamNew App newApp

We intend to extend this principle further by writing scripts to create templates for new run-time selectable modules e.g. boundary-conditions, thermophysical models, turbulence models etc. etc. but we haven't had time so far and have decided to make these and documentation of the coding style and conventions part of the programmers guide which we will start writing as soon as we find sponsorship for this work.

2 Indentation

The indentation of a C++-program doesn't affect the syntactical correctness of that program. Therefor any programmer may use the indentation style he likes best. Some editors (like XEmacs) assist you with the indentation of the source. Problems arise if one changes a OpenFOAM-source-file because the text-editor might mess up the source-file, making it difficult to track changes with the original.

2.1 Emacs/XEmacs

For the various Emacs flavours a solution exists and is found here.