C++ Style

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2007
Posts: 269
Reputation: sarehu is on a distinguished road 
Solved Threads: 22
sarehu's Avatar
sarehu sarehu is offline Offline
Posting Whiz in Training

C++ Style

 
1
  #1
Jul 4th, 2008
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,833
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 503
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: C++ Style

 
0
  #2
Jul 4th, 2008
Originally Posted by sarehu View Post
What do you think of this?

http://google-styleguide.googlecode....k/cppguide.xml
This looks like a great link! I've bookmarked it. I was looking at the threads pinned to the top and noticed that there is one at the top regarding C++ books, but not C++ websites. I think one should be started and this link should be in there. Good post.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,953
Reputation: Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of 
Solved Threads: 214
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: C++ Style

 
0
  #3
Jul 4th, 2008
Use only spaces, and indent 2 spaces at a time.
Yes! Vindication!

Bwaa hah hah hah ha haah


PS I don't like tabs.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,833
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 503
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: C++ Style

 
0
  #4
Jul 4th, 2008
Originally Posted by Duoas View Post
Yes! Vindication!

Bwaa hah hah hah ha haah


PS I don't like tabs.
Tabs are cool, but they look like hell on Daniweb if you aren't careful because a tab is like eight spaces so it overflows onto the next line a lot. What looks the worst is if people mix tabs and spaces and then post on Daniweb. If they have fours spaces per tab in their IDE, which is then changed to eight on Daniweb, the indentation gets all messed up. If you just use spaces it'll look fine wherever it's posted.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 269
Reputation: sarehu is on a distinguished road 
Solved Threads: 22
sarehu's Avatar
sarehu sarehu is offline Offline
Posting Whiz in Training

Re: C++ Style

 
0
  #5
Jul 4th, 2008
Congratulations, you've singled out the least important part of the style guide.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,802
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 747
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: C++ Style

 
1
  #6
Jul 5th, 2008
Good advice in general. The particularly noticeable poor advice is smoothed out by clearly being specific to Google and practicality with their existing code base. While I can see their reasoning, I very much dislike their stance on exceptions. Hopefully non-Google people reading this guide will ignore that convention.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,953
Reputation: Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of 
Solved Threads: 214
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: C++ Style

 
0
  #7
Jul 5th, 2008
Sarehu
The purpose of "style guides" is twofold:
  1. Readability -- Physical layout of source code
  2. Interoperability -- Structural layout of data (functions, variables, etc)
Failure on either account costs significant amounts in terms of cold, hard cash. Business concerns make or break in terms of the amount of time you waste on a project.

I dislike tabs because they don't play nice. Most editors I've used (and I've tried just about every one you can name to me) handle tabs either incorrectly or just plain differently than the editor the guy four cubicles down does. In one case incorrect tab handling actually changed the meaning of my code. But sure, small potatoes.

Lighten up.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: C++ Style

 
0
  #8
Jul 5th, 2008
Tabs are a definite no no.

I write code for a living and my employer (my mom) says I should use only SPACES - otherwise there won't be any milk and cookies for tea.

God has spoken.
Last edited by iamthwee; Jul 5th, 2008 at 9:12 pm.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,553
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1484
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: C++ Style

 
0
  #9
Jul 5th, 2008
Originally Posted by sarehu View Post
Congratulations, you've singled out the least important part of the style guide.
Not so, tabs are the most visible. They can destroy the whole program no matter how well-written it is. Tabs look crappy when use in code tags here at DaniWeb because they can render the code almost unreadable.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: C++ Style

 
0
  #10
Jul 6th, 2008
Just say no to tabs.

Here's why.

1. Almost all forums make a complete mess of tabs, unless you've been exceptionally dilligent in your use of tabs to begin with. ANY mixing of spaces and tabs will destroy the indentation when posted online. Take this example which uses 4 spaces for 1 tab.
  1. int main ( ) {
  2. int a; // 4 spaces
  3. int b; // 1 tab
  4. int c; // 2 spaces + tab
  5. }
Looks great in my editor, but just sucks and blows at the same time when posted here!.

Given the standard of comprehension and indentation skills (99% can't even use code tags, let alone indent properly), there's no hope.

2. There is no set standard for what a tab should be (ok, there is, it's 8 spaces). But all too often, some smarty-pants has configured code-wrangler 4.2 to make a tab equal 4 spaces. All very good, if that's the only tool you use.

But by the time you're working on a large project, with many different people using all sorts of tools (lint, diff, merge, doxygen, pretty-print, indent etc etc), sooner or later, you're going to end up with a visual mess.

Add to that, if you decide to use several 3rd party libraries (each with their own 1-tab == x-spaces settings (all different)), then you have yet another unholy mess.

If you use only spaces, you GUARANTEE that it looks the same everywhere.

Any code editor worthy of the name has an automatic way of substituting spaces for tabs. Most have "smart" indentation anyway, so there's really no worry about having to hammer the space bar to achieve the indentation you want.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC