Hi Folks,
I'm wondering if there is a compilation of C++ guidelines out there
anywhere. Here are some of the ones I've picked up so far (as examples):
- Functions should fit on one screen, from various sources.
- Non-leaf classes should be abstract (have pure virtual methods), from
More Effective C++, Item 33.
- Virtual methods should be private by default and protected if they
need access to a base classes version (except for the destructor, of
course), from http://www.gotw.ca/publications/mill18.htm.
- Header files should be self contained, from various sources.
- Destructors for base classes should be either virtual or protected.
I think I've probably missed (or never heard of) quite a few more.
Anyone know where I can find such things? Or have some guidelines of
their own to share?
-- Pete
Jul 22 '05
64 3374
Steven T. Hatton wrote:
[snip] But, I believe you are looking for just about the same kind of resource I have been wanting. Have you found a winner yet?
Of the books I have read so far, the following have been extremely useful:
Effective C++
More Effective C++
Effective STL
Exceptional C++
More Exceptional C++
.... not exactly guideline books, but still good: TC++PL, Design
Patterns, Modern C++ Design, etc.
And the articles at www.gotw.ca are good. Also, there are many good
articles at www.cuj.com (if you dig around the archives).
Other than that I have found very little.
-- Pete
Joe Gottman wrote:
[snip] - Destructors for base classes should be either virtual or protected.
Never heard of the "protected" one.
[snip]
Neither had I, which was /exactly/ why I started this thread. To try and
find more of these guidelines.
-- Pete
Joe Gottman wrote:
[snip] - Destructors for base classes should be either virtual or protected.
Never heard of the "protected" one.
[snip]
Neither had I, which was /exactly/ why I started this thread. To try and
find more of these guidelines.
-- Pete
Pete Vidler wrote: Joe Gottman wrote: [snip]- Destructors for base classes should be either virtual or protected.
Never heard of the "protected" one.
[snip]
Neither had I, which was /exactly/ why I started this thread. To try and find more of these guidelines.
-- Pete
Here's one I tend to use in Java, and believe it applies to C++ as well. In
C++ terms it would be use /out/ not /std::cout/. That is, create a
variable /out/ of type std::ostream. Do this, say in the parameter list of
a function. Then when you call the function you pass std::cout, or some
other instance of std::ostream.
Unfortunately, I am not familiar enough with the STL <iostream> to know
exactly what level of abstraction to use. E.g., there is a distinction
between std::cout, and std::wcout.
The same also applies to input streams.
The idea is to write code that doesn't care what it's writing to/reading
from, just so long as it has a stream. This is handy, for example, when
you write code that can be run from the commandline and dumps to console,
or can be run from a web server and writes to the network.
--
STH
Hatton's Law: "There is only One inviolable Law"
KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
Mozilla: http://www.mozilla.org
Pete Vidler wrote: Joe Gottman wrote: [snip]- Destructors for base classes should be either virtual or protected.
Never heard of the "protected" one.
[snip]
Neither had I, which was /exactly/ why I started this thread. To try and find more of these guidelines.
-- Pete
Here's one I tend to use in Java, and believe it applies to C++ as well. In
C++ terms it would be use /out/ not /std::cout/. That is, create a
variable /out/ of type std::ostream. Do this, say in the parameter list of
a function. Then when you call the function you pass std::cout, or some
other instance of std::ostream.
Unfortunately, I am not familiar enough with the STL <iostream> to know
exactly what level of abstraction to use. E.g., there is a distinction
between std::cout, and std::wcout.
The same also applies to input streams.
The idea is to write code that doesn't care what it's writing to/reading
from, just so long as it has a stream. This is handy, for example, when
you write code that can be run from the commandline and dumps to console,
or can be run from a web server and writes to the network.
--
STH
Hatton's Law: "There is only One inviolable Law"
KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
Mozilla: http://www.mozilla.org
Pete Vidler wrote: What I am looking for is what I posted originally -- guidelines similar to the ones I posted. I'm not looking for a book describing individual C++ features, but rather a book describing (the authors) best practices in /using/ them.
This thread has revolved around such books.
I'm not looking for software design info (large scale or otherwise), but guidelines on using C++ effectively.
You are having reading comprehension issues. Lakos' book is about physical
construction - the do's and don't's of implementation. Its forward expressly
states it is not about "design" in the abstract.
Stop complaining about everyone's quite valid recommendations .
--
Phlip http://www.xpsd.org/cgi-bin/wiki?Tes...UserInterfaces
Pete Vidler wrote: What I am looking for is what I posted originally -- guidelines similar to the ones I posted. I'm not looking for a book describing individual C++ features, but rather a book describing (the authors) best practices in /using/ them.
This thread has revolved around such books.
I'm not looking for software design info (large scale or otherwise), but guidelines on using C++ effectively.
You are having reading comprehension issues. Lakos' book is about physical
construction - the do's and don't's of implementation. Its forward expressly
states it is not about "design" in the abstract.
Stop complaining about everyone's quite valid recommendations .
--
Phlip http://www.xpsd.org/cgi-bin/wiki?Tes...UserInterfaces
"Pete Vidler wrote: Never heard of the "protected" one.
Neither had I, which was /exactly/ why I started this thread. To try and find more of these guidelines.
Did you read the C++ FAQ?
You have read enough to start coding. If you only do the intersection - not
the union - of those books' recommendations , you will have a sufficiently
narrow sane subset.
--
Phlip http://www.xpsd.org/cgi-bin/wiki?Tes...UserInterfaces
Phlip wrote: "Pete Vidler wrote:
>Never heard of the "protected" one. Neither had I, which was /exactly/ why I started this thread. To try and find more of these guidelines.
Did you read the C++ FAQ?
That came out wrong.
Did you read the _book_ /C++ FAQs/ by Marshall Cline?
You have read enough to start coding. If you only do the intersection -
not the union - of those books' recommendations , you will have a sufficiently narrow sane subset.
-- Phlip http://www.xpsd.org/cgi-bin/wiki?Tes...UserInterfaces
"Siemel Naran" <Si*********@RE MOVE.att.net> wrote in message
news:Lu******** **********@bgtn sc05-news.ops.worldn et.att.net... - Non-leaf classes should be abstract (have pure virtual methods), from More Effective C++, Item 33. A suggestion. Sometimes we want a reasonable default behavior which
clients can then override. Requring the above as a guideline imposes too much design burden on the project and could cause it to run out of budget.
Agreed. I don't like that "guideline" very much. - Header files should be self contained, from various sources.
What?
Makes sense to me, and I wholeheartedly agree. Nothing worse than
unnecessary dependencies in header files. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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?
|
by: stevehayter |
last post by:
Wonder if anyone can help me solve this problem!
I have a 3x3 table which i'm using to create a table with a rounded
edge using images in the top left, top right, bottom left, and bottom
right cells and lines in the top/left/right and bottom cells (sounds
odd, you'll see what i mean when you see the site). It works fine,
except the top and bottom rows are a lot bigger than i've specified
when they should be flush with the centre cell as...
|
by: Pete Vidler |
last post by:
Hi Folks,
I'm wondering if there is a compilation of C++ guidelines out there
anywhere. Here are some of the ones I've picked up so far (as examples):
- Functions should fit on one screen, from various sources.
- Non-leaf classes should be abstract (have pure virtual methods), from
More Effective C++, Item 33.
|
by: E. Robert Tisdale |
last post by:
C++ Programming Style Guidelines
http://geosoft.no/development/cppstyle.html
I think that these guidelines are almost *all* wrong.
For example:
11. Private class variables should have underscore suffix.
class SomeClass {
private:
|
by: jamilur_rahman |
last post by:
What is the BIG difference between checking the "if(expression)" in A
and B ? I'm used to with style A, "if(0==a)", but my peer reviewer
likes style B, how can I defend myself to stay with style A ?
style A:
....
....
int a = 1;
if(0==a)
{
| |
by: John Salerno |
last post by:
Does Microsoft have any naming guidelines for variables? I've been
reading their guidelines for just about every other type (methods,
parameters, properties, etc.) but nothing about variables. Are variables
treated the same as parameters (i.e., camel case)?
I notice that Hungarian notation is being done away with.
Also, is it good practice to use an underscore to begin the name of a
field? I've seen that, and it seems like a good idea,...
|
by: Laurent Bugnion [MVP] |
last post by:
Hi group,
In agreement with the head of our R&D department, I published my firm's
JavaScript Coding Guidelines. I work for Siemens Building Technologies.
We developed these guidelines for a web application project in 2004,
based on our C# guidelines.
http://www.galasoft-lb.ch/myjavascript/Siemens_SBT_JavaScript_Coding_Guidelines.pdf
Please note the following:
|
by: mrashidsaleem |
last post by:
Can anyone guide me what is wrong with the naming conventions
suggested below? I know that this is not recommended by many
(including Microsoft) but I need to know what exactly is the rationale
behind going for a different convention in .NET. The recommendations
do make sense (to me, at least but I may be wrong and would like
someone to correct me).
Scope Prefixes
Member Variable Prefix: Most of the people still use (and like the
idea...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |