C++ Code Optimization: 10 Tips And Tricks

C++ is a great enterprise programming language if you know how to get the most from its arcane features. Here are 10 tips to help you do so, and end up with high-performing applications for your business.
Reduce, Reuse, Recycle
Minimize Temporary Objects
Keep Memory Together
= != ==
Keep Local Variables Local
Use Unary Operators In The Right Place
Use The Makefile
Compile Different
Flowcharts Are Cool
Focus On The Algorithm

When it comes to enterprise programming, C++ reigns supreme. That's one of the reasons why figuring out how to write the best C++ code possible is a hot topic on the Web. Another reason programmers come together to figure out best practices for C++ programming is the nature of the language itself. C++ gets its underlying structure from C, exists in multiple versions, and is wildly configurable and extensible. It is possible to use those qualities to write compact, efficient, elegant code in C++. It's equally possible to use those qualities to write a resource-devouring mess.

There are a lot of ways to nibble at the problem of bad C++ code. If you don't believe me, a quick Google search will prove the point. But which tips can have a larger impact on code quality? I took a look and came up with 10 that I believe might make a difference in the way your code behaves and the impact it has on the system as a whole.

[ Just getting started? Read 10 Top Programming Languages For Learning To Code.]

It's important to note that two of the tips in this article could apply to any programming language. They don't even require a computer. The rest, though, assume that you're actually writing some code in C++ and have the ability to compile it into executable code. Two of these are concerned with how you compile your code, leaving six that deal with the code you write.

As I mentioned upfront, these are suggestions that I think will have a real impact on your work. They're among thousands of tips that exist. Once you've reviewed them, tell me whether you think they're some of the best? I'd love to hear your thoughts and exchange some practical information with you in the comments section below. Which tactics and techniques have helped your code? Who knows, maybe you'll be featured in a future "how we code" article right here at InformationWeek.

**New deadline of Dec. 18, 2015** Be a part of the prestigious InformationWeek Elite 100! Time is running out to submit your company's application by Dec. 18, 2015. Go to our 2016 registration page: InformationWeek's Elite 100 list for 2016.

Next slide