473,480 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

C++ Style Standards

I was wondering how good this page of coding standards
(http://www.doc.ic.ac.uk/lab/cplus/c++.rules/) is.

Is it too outdated?
Jul 22 '05 #1
7 1636

"Cameron Hatfield" <cameron930ATcomcastDOTnet> wrote in message
news:bO********************@comcast.com...
I was wondering how good this page of coding standards
(http://www.doc.ic.ac.uk/lab/cplus/c++.rules/) is.

Is it too outdated?


Seems so, I just clicked one link and saw "void main". I did not bother to
go further.
http://www.doc.ic.ac.uk/lab/cplus/c+...ap9.html#sect1

-Sharad
Jul 22 '05 #2
On Tue, 13 Jul 2004 21:53:00 -0700, Cameron Hatfield
<cameron930ATcomcastDOTnet> wrote:
I was wondering how good this page of coding standards
(http://www.doc.ic.ac.uk/lab/cplus/c++.rules/) is.

Is it too outdated?


I think there is a lot of good advice there, but it is far too rigid for
my taste. I think it you follow rules like that to the letter you end up
with code that is less good than if you've just used a bit of common
sense. Most of the time I'd agree with most of the rules however.

A couple of points I noted where it was out of date were namespaces and
the mutable keyword. The author clearly wasn't aware of either of those. I
couldn't see any mention of exceptions either. I didn't read the whole
document so there are probably other places where it is outdated.

john
Jul 22 '05 #3
Cameron Hatfield wrote:
I was wondering how good this page of coding standards
(http://www.doc.ic.ac.uk/lab/cplus/c++.rules/) is.
Ah, someone got paid for a week to write a Web site instead of source
code...
Is it too outdated?


It contains a 'void main', which reveals cluelessness.

"Do not use unspecified function arguments (ellipsis notation)." is kosher.
"Optimize code only if you /know/ that you have a performance problem" is
advice too many /still/ need. "Compile with all warnings turned on" is
correct - if you can turn a few off individually. "The public, protected,
and private sections of a class are to be declared in that order" is okay,
but could mention classes should be so short the rule's not needed.

"No member functions are to be defined within the class definition" is a
strategy to deal with inline. Either inline everything or nothing, then only
use performance tuning and profiling to detect which thing's inline status
needs changing. But the rule "put classes in .cpp file without overwhelming
reasons to put them in .h files" could have worked better. That's a
specialization of "give identifiers the narrowest scope possible."

The section for Variables is harmless, except it says "Variables are to be
declared with the smallest possible scope.". This rule should apply to any
identifier, not just variables. These rules are against C style code that
declares billions of variables at the top of a long method, and then doesn't
assign them all.

It doesn't seem to mention automated unit tests. The rule "Never specify
public or protected member data in a class" is a little bit LESS important
than "test every line, duh!"

The rule "Never specify public or protected member data in a class" really
means "don't make primitive things globally accessible".

The rule "The identifier of every globally visible class, enumeration type,
type definition, function, constant, and variable in a class library is to
begin with a prefix that is /unique/ for the library" predates namespaces. I
t's the "Registered Package Prefix" system from /Large Scale C++ Software
Design/.

The guidelines mix esthetic and technical recommendations annoyingly, to
follow the general outline.

The section for "Pointers and References" doesn't mention, technically, to
prefer references without a reason to point.

The recommendation "An include file should not contain more than one class
definition" is stupid. Header files should contain enough stuff to solve one
problem. A few small classes colluding to solve one problem are generally
more comprehensible than one big one, or many header files that always go
together. The verbiage could have saved itself by recommending one
uber-class nest all its minion classes inside itself, but instead the
verbiage just says "no exceptions".

The stuff about comments is essentially "code deodorant". One should clean
up stinky code, instead of deodorize it.

"Never use explicit UNIX path names" is incorrect. / slash works fine on
Win32.

The stuff about variable naming should say "names should reveal intent, and
be pronouncable". The (literally) global variable "WWW" fails both those
checks.

'A class which uses "new" to allocate instances managed by the class, [i.e.
instances bound to member variables of pointer or reference type that are
deallocated by the object.] must define a copy constructor. ' The better
advice here is to either don't call 'new', or to write very small classes
that call it, then use these classes as members.

This advice predates STL, and contains much /Effective C++/ stuff. A C-minus
effort like this reveals Scott Meyers's brilliance, narrowing these rules
down to their absolute cores.

The rules about switch statements could mention replacing conditionals on
typecodes with polymorphism. That's the heart of the Object Oriented
paradigm, and these rules are generally mired in "C style C++" land.

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces

Jul 22 '05 #4
"Sharad Kala" <no******************@yahoo.com> wrote in message
news:2l************@uni-berlin.de...

"Cameron Hatfield" <cameron930ATcomcastDOTnet> wrote in message
news:bO********************@comcast.com...
I was wondering how good this page of coding standards
(http://www.doc.ic.ac.uk/lab/cplus/c++.rules/) is.

Is it too outdated?


Seems so, I just clicked one link and saw "void main". I did not bother to
go further.
http://www.doc.ic.ac.uk/lab/cplus/c+...ap9.html#sect1

-Sharad


Happen to have any others to reccomend? (Any of the ones in the FAQ in
paticular, or not in it)

Cameron
Jul 22 '05 #5

"Cameron Hatfield" <cameron930ATcomcastDOTnet> skrev i en meddelelse
news:1P********************@comcast.com...
"Sharad Kala" <no******************@yahoo.com> wrote in message
news:2l************@uni-berlin.de...

"Cameron Hatfield" <cameron930ATcomcastDOTnet> wrote in message
news:bO********************@comcast.com...
I was wondering how good this page of coding standards
(http://www.doc.ic.ac.uk/lab/cplus/c++.rules/) is.

Is it too outdated?


Seems so, I just clicked one link and saw "void main". I did not bother to go further.
http://www.doc.ic.ac.uk/lab/cplus/c+...ap9.html#sect1

-Sharad


Happen to have any others to reccomend? (Any of the ones in the FAQ in
paticular, or not in it)

Cameron

http://cvs.sourceforge.net/viewcvs.p...ing_guidelines

/Peter
Jul 22 '05 #6
> Cameron Hatfield skrev:
Happen to have any others to reccomend? (Any of the ones in the FAQ in
paticular, or not in it)


/Agile Development: Principles Practices and Patterns/ by Robert C.
Martin

/AntiPatterns: refactoring software, architectures, and projects in
crisis/ by
Brown, Malveau, McCormick & Mowbray

/The C++ Programming Language/ by Bjarne Stroustrup

/Code Complete 2nd Edition/ by Steve McConnell

/Design Patterns/ by Gamma, Johnson, Helm, & Vlissides

/Domain Driven Design: Tackling Complexity in the Heart of Software/
by
Eric Evans

/Effective C++, 2nd Edition/ by Scott Meyers

/Exceptional C++/ by Herb Sutter

/How to Break Software: A Practical Guide to Testing/ by James A.
Whittaker

/Large Scale C++ Software Design/ by John Lakos

/Modern C++ Design: Generic Programming and Design Patterns
Applied/ by Andrei Alexandrescu

/More Effective C++/ by Scott Meyers

/The Pragmatic Programmer: From Journeyman to Master/ by Andy Hunt
& Dave Thomas

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces
Jul 22 '05 #7
"Cameron Hatfield" <cameron930ATcomcastDOTnet> wrote in message
news:bO********************@comcast.com...
I was wondering how good this page of coding standards
(http://www.doc.ic.ac.uk/lab/cplus/c++.rules/) is.

Is it too outdated?


I found this one pretty good. http://www.codingstandard.com/
However, to me a coding standard is really just a naming convention like...
ClassName, StructName or EnumName
functionName
m_attributeName
CONSTANT or ENUM ELEMENT
etc.
After that, the rest of it is common sense stuff. :)

Also, Herb Sutter and Andrei Alexandrescu are writing a book called C++
Coding Standards.
http://www.amazon.com/exec/obidos/tg...books&n=507846

However, it won't be out until November I think.

I hope this helps!
Limech

Jul 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
2185
by: beliavsky | last post by:
Is there a more recent set of Python style guidelines than PEP 8, "Style Guide for Python Code", by van Rossum and Warsaw, at http://www.python.org/peps/pep-0008.html , which is dated July 5, 2001?
15
32646
by: Matthias Hullin | last post by:
Hi, I'm programming some PHP discussion board that is supposed to appear inside the content area of a proprietary CMS. As I need some more styles than the standard stylesheet provides, I just...
108
6290
by: Bryan Olson | last post by:
The Python slice type has one method 'indices', and reportedly: This method takes a single integer argument /length/ and computes information about the extended slice that the slice object would...
15
1972
by: Earl Higgins | last post by:
The company where I work as a Senior Software Engineer is currently revamping their (1991 era) "Programming and Style Guidelines", and I'm on the committee. The company, in business for over 20...
144
6728
by: Natt Serrasalmus | last post by:
After years of operating without any coding standards whatsoever, the company that I recently started working for has decided that it might be a good idea to have some. I'm involved in this...
4
2218
by: jarek | last post by:
Hi, this is my code: CSSStyleDeclaration.prototype.__defineSetter__('display', displaySetter); function displaySetter(value) { var parent = findParent(document, this); if (parent) {
3
2110
by: MIS Director | last post by:
Is there any tool out there that will analyze an entire website and produce a report of inline style usages by both total count and detail occurrances. This would produce a list of possible...
100
4603
by: Angel Tsankov | last post by:
Can someone recommend a good source of C/C++ coding style. Specifically, I am interested in commenting style and in particular how to indent comments and the commented code, rather than when to...
13
2467
by: stephenpas | last post by:
We are trying to monkey-patch a third-party library that mixes new and old-style classes with multiple inheritance. In so doing we have uncovered some unexpected behaviour: <quote> class Foo:...
0
7054
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6918
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4798
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4495
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3000
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1310
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
570
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
199
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.