473,548 Members | 2,593 Online
Bytes | Software Development & Data Engineering Community
+ 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 1642

"Cameron Hatfield" <cameron930ATco mcastDOTnet> wrote in message
news:bO******** ************@co mcast.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
<cameron930ATco mcastDOTnet> 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.co m> wrote in message
news:2l******** ****@uni-berlin.de...

"Cameron Hatfield" <cameron930ATco mcastDOTnet> wrote in message
news:bO******** ************@co mcast.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" <cameron930ATco mcastDOTnet> skrev i en meddelelse
news:1P******** ************@co mcast.com...
"Sharad Kala" <no************ ******@yahoo.co m> wrote in message
news:2l******** ****@uni-berlin.de...

"Cameron Hatfield" <cameron930ATco mcastDOTnet> wrote in message
news:bO******** ************@co mcast.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" <cameron930ATco mcastDOTnet> wrote in message
news:bO******** ************@co mcast.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
2193
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
32653
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 added a <style> tag inside my HTML code. It works fine in all the browsers I tested, but it seems to be more of a hack than a valid solution.
108
6325
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 describe if applied to a sequence of length items. It returns a tuple of three integers; respectively these are the /start/ and /stop/ indices and...
15
1982
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 years, writes medical software, which must ultimately pass FDA approval and ISO 9000 certification. The product the document applies to is a large...
144
6765
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 initiative. Typically I find that coding standards are written by some guy in the company who has a way of coding that he likes and then tries to force...
4
2223
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
2114
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 candidates to put in the css and replace those occurrances with the style or class in pages. Just to do a search of style tags in Dreamweaver produces a...
100
4635
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 use comments. Thanks in advance! -- http://www.gotw.ca/resources/clcm.htm for info about ]
13
2476
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: pass class Bar(object): pass
0
7512
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7951
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7803
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5082
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3495
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1926
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 we have to send another system
1
1051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
751
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.