Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 48359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:16:03+00:00 2026-05-10T16:16:03+00:00

What guidelines do you follow to improve the general quality of your code? Many

  • 0

What guidelines do you follow to improve the general quality of your code? Many people have rules about how to write C++ code that (supposedly) make it harder to make mistakes. I’ve seen people insist that every if statement is followed by a brace block ({...}).

I’m interested in what guidelines other people follow, and the reasons behind them. I’m also interested in guidelines that you think are rubbish, but are commonly held. Can anyone suggest a few?

To get the ball rolling, I’ll mention a few to start with:

  • Always use braces after every if / else statement (mentioned above). The rationale behind this is that it’s not always easy to tell if a single statement is actually one statement, or a preprocessor macro that expands to more than one statement, so this code would break:
     // top of file:     #define statement doSomething(); doSomethingElse      // in implementation:     if (somecondition)         doSomething(); 

but if you use braces then it will work as expected.

  • Use preprocessor macros for conditional compilation ONLY. preprocessor macros can cause all sorts of hell, since they don’t allow C++ scoping rules. I’ve run aground many times due to preprocessor macros with common names in header files. If you’re not careful you can cause all sorts of havoc!

Now over to you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T16:16:04+00:00Added an answer on May 10, 2026 at 4:16 pm

    A few of my personal favorites:

    Strive to write code that is const correct. You will enlist the compiler to help weed out easy to fix but sometimes painful bugs. Your code will also tell a story of what you had in mind at the time you wrote it — valuable for newcomers or maintainers once you’re gone.

    Get out of the memory management business. Learn to use smart pointers: std::auto_ptr, std::tr1::shared_ptr (or boost::shared_ptr) and boost::scoped_ptr. Learn the differences between them and when to use one vs. another.

    You’re probably going to be using the Standard Template Library. Read the Josuttis book. Don’t just stop after the first few chapters on containers thinking that you know the STL. Push through to the good stuff: algorithms and function objects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 65k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You can write your own EncoderFallback class assign that to… May 11, 2026 at 11:14 am
  • added an answer If you can identify the files based on extension, you… May 11, 2026 at 11:14 am
  • added an answer the BOL actually states: The following functions are not always… May 11, 2026 at 11:14 am

Related Questions

What guidelines do you follow to improve the general quality of your code? Many
In your object-oriented language, what guidelines do you follow for grouping classes into a
What guidlines do you use when deciding whether to let a method dodge an
What are some guidelines for maintaining responsible session security with PHP? There's information all
What are some guidelines for displaying information to a user in a web-browser? I
What are general guidelines on when user-defined implicit conversion could, should, or should not
When creating a database structure, what are good guidelines to follow or good ways
What should be the general guidelines/gotchas for dividing application code (App_Code) into separate files?
What are the C++ coding and file organization guidelines you suggest for people who
Are there any guidelines/best practices for deciding what type of data should be stored

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.