Key Points

  • Structures can help make programs less complicated, easier to understand, and easier to maintain.

  • Whenever you consider using a structure, consider whether a class would work better.

  • Pointers are error-prone. Protect yourself by using access routines or classes and defensive-programming practices.

  • Avoid global variables, not just because they're dangerous, but because you can replace them with something better.

  • If you can't avoid global variables, work with them through access routines. Access routines give you everything that global variables give you, and more.

Get Code Complete, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.