Effective C++: 50 Simple Ways to Improve Your Programs and Designs / Edition 1

Paperback (Print)
Used and New from Other Sellers
Used and New from Other Sellers
from $1.99
Usually ships in 1-2 business days
(Save 95%)
Other sellers (Paperback)
  • All (44) from $1.99   
  • New (2) from $9.95   
  • Used (42) from $0.00   
Close
Sort by
Page 1 of 1
Showing All
Note: Marketplace items are not eligible for any BN.com coupons and promotions
$9.95
Seller since 2005

Feedback rating:

(69)

Condition:

New — never opened or used in original packaging.

Like New — packaging may have been opened. A "Like New" item is suitable to give as a gift.

Very Good — may have minor signs of wear on packaging but item works perfectly and has no damage.

Good — item is in good condition but packaging may have signs of shelf wear/aging or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Acceptable — item is in working order but may show signs of wear such as scratches or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Used — An item that has been opened and may show signs of wear. All specific defects should be noted in the Comments section associated with each item.

Refurbished — A used item that has been renewed or updated and verified to be in proper working condition. Not necessarily completed by the original manufacturer.

New
1991-12-30 Paperback 1 New 0201563649 New paperback-same as pictured-over10, 000 books sold-Paperback--100% guarantee-e-mail confirmation of order-Same or next day mailin.

Ships from: Penrose, CO

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$45.00
Seller since 2014

Feedback rating:

(165)

Condition: New
Brand new.

Ships from: acton, MA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
Page 1 of 1
Showing All
Close
Sort by

Product Details

  • ISBN-13: 9780201563641
  • Publisher: Addison Wesley Professional
  • Publication date: 2/28/1992
  • Series: Professional Computing Series
  • Edition description: Older Edition
  • Edition number: 1
  • Pages: 224
  • Product dimensions: 7.39 (w) x 9.21 (h) x 0.63 (d)

Read an Excerpt

PREFACE:This book is a direct outgrowth of my experiences teaching C++ to professional programmers through the Institute for Advanced Professional Studies. I found that most students, after a week of intensive instruction, felt comfortable with the basic constructs of the language, but were less sanguine about their ability to put the constructs together in an effective manner. Thus began my attempt to formulate short, specific, easy-to-remember guidelines for effective software development in C++: a summary of the things that experienced C++ programmers either almost always do or almost always avoid.

As a computer scientist, I was originally interested in rules that could be checked by a machine. To that end, I outlined a program to examine C++ software for constructs that were "almost always wrong." Currently under development, this checking program has become known as lint++. However, it quickly became apparent that the great majority of the guidelines used by good C++ programmers were too difficult to formalize, or had too many important exceptions, to be blindly enforced by a lint++-like program.

That led me to the notion of something less precise than a computer program but still more focused and to-the-point than a general C++ textbook. The result you now hold in your hands: a book containing 50 specific suggestions on how to improve your C++ programs and designs.

In this book you'll find advice on what you should do, and why, and what you should not do, and why not. Fundamentally, of course, the whys are much more important than the whats, but from a purely pragmatic point of view, it is much more convenient to have a list ofguidelines in front of you than it is to memorize a textbook or two. Unlike most books on C++, my presentation here is not organized around particular language features. That is, I don't talk about constructors in one place, aboutvirtual functions in another, about inheritance in a third, etc. Instead, each explanation is tightly coupled to the specific guideline it accompanies, and my coverage of the various aspects of a particular feature is typically dispersed throughout the book.

The advantage of this approach is that it better reflects the complexity of the software systems for which C++ is often chosen, systems in which the understanding of individual language features is not enough. For example, experienced C++ developers know that understanding inline functions and understanding virtual destructors does not necessarily mean that you understand inline virtual destructors. Such battle-scarred developers recognize that comprehending the interactions between the features in C++ is of the greatest possible importance in using the language effectively. The organization of this book reflects that fundamental truth.

The disadvantage of my approach is that you may have to look in more than one place to discover everything I have to say about a particular construct in C++. To minimize the inconvenience inherent in this approach, I have sprinkled cross-references liberally throughout the text, and a comprehensive index is provided at the end of the book.

The set of guidelines in this book is far from exhaustive, but coming up with good rules - ones that are applicable to almost all applications almost all the time - is harder than it looks. Perhaps you know of additional guidelines, of more ways in which to program effectively in C++. If so, I would be delighted to hear about them.

On the other hand, you may feel that some of the items in this book are inappropriate as general advice; that there is a better way to accomplish a task examined in the book; or that one or more of the technical discussions is unclear, incomplete, or misleading. I encourage you to let me know about these things, too.

Donald Knuth has a long history of offering a small reward for people who notify him of errors in his books. The quest for a perfect book is laudable in any case, but in view of the number of bug-ridden C++ books that have been rushed to market, I feel especially strongly compelled to follow Knuth's example. Therefore, for each error in this book that is reported to me - be it technical, grammatical, typographical, or otherwise - I will, in future printings, gladly acknowledge the first person to report that error.

Send your suggested guidelines, your comments, your criticisms, and - sigh - your bug reports to:

Scott Meyersc/o Editor-in-Chief, Corporate and Professional Publishing
Addison-Wesley Publishing Company
1 Jacob Way
Reading, MA 01867
U. S. A.

Alternatively, you may send electronic mail to johnw@aw.com.

I maintain a list of changes to this book since its first printing, including bug-fixes, clarifications, and technical updates. This list is available via anonymous FTP from the Internet site ftp.aw.com in the directory cp/ec++. If you would like a copy of this file, but you lack access to the Internet, please send a request to one of the addresses above, and I will see that the list is sent to you.

Scott Douglas Meyers
Providence, RI
November 1991

Read More Show Less

Table of Contents

Shifting from C to C++.
Item 1: Use const and inline instead of #define.
Item 2: Prefer iostream.h to stdio.h.
Item 3: Use new and delete instead of malloc and free.
Item 4: Prefer C++-style comments.

Memory Management.
Item 5: Use the same form in corresponding calls to new and delete.
Item 6: Call delete on pointer members in destructors.
Item 7: Check the return value of new.
Item 8: Adhere to convention when writing new.
Item 9: Avoid hiding the global new.
Item 10: Write delete if you write new.

Constructors, Destructors, and Assignment Operators.
Item 11: Define a copy constructor and an assignment operator for classes with dynamically allocated memory.
Item 12: Prefer initialization to assignment in constructors.
Item 13: List members in an initialization list in the order in which they are declared.
Item 14: Make destructors virtual in base classes.
Item 15: Have operator= return a reference to *this.
Item 16: Assign to all data members in operator=.
Item 17: Check for assignment to self in operator=.
Classes and Functions: Design and Declaration.
Item 18: Strive for class interfaces that are complete and minimal.
Item 19: Differentiate among member functions, global functions, and friend functions.
Item 20: Avoid data members in the public interface.
Item 21: Use const whenever possible.
Item 22: Pass and return objects byreference instead of by value.
Item 23: Don't try to return a reference when you must return an object.
Item 24: Choose carefully between function overloading and parameter defaulting.
Item 25: Avoid overloading on a pointer and a numerical type.
Item 26: Guard against potential ambiguity.
Item 27: Explicitly disallow use of implicitly generated member functions you don't want.
Item 28: Use structs to partition the global namespace.

Classes and Functions: Implementation.
Item 29: Avoid returning "handles" to internal data from const member functions.
Item 30: Avoid member functions that return pointers or references to members less accessible than themselves.
Item 31: Never return a reference to a local object or a dereferenced pointer initialized by new within the function.
Item 32: Use enums for integral class constants.
Item 33: Use inlining judiciously.
Item 34: Minimize compilation dependencies between files.

Inheritance and Object-Oriented Design.
Item 35: Make sure public inheritance models "isa".
Item 36: Differentiate between inheritance of interface and inheritance of implementation.
Item 37: Never redefine an inherited nonvirtual function.
Item 38: Never redefine an inherited default parameter value.
Item 39: Avoid casts down the inheritance hierarchy.
Item 40: Model "has-a" or "is-implemented-in-terms-of" through layering.
Item 41: Use private inheritance judiciously.
Item 42: Differentiate between inheritance and templates.
Item 43: Use multiple inheritance judiciously.
Item 44: Say what you mean; understand what you're saying.

Miscellany.
Item 45: Know what functions C++ silently writes and calls.
Item 46: Prefer compile-time and link-time errors to runtime errors.
Item 47: Ensure that global objects are initialized before they're used.
Item 48: Pay attention to compiler warnings.
Item 49: Plan for coming language features.
Item 50: Read the ARM.

Index.
Read More Show Less

Preface

PREFACE:This book is a direct outgrowth of my experiences teaching C++ to professional programmers through the Institute for Advanced Professional Studies. I found that most students, after a week of intensive instruction, felt comfortable with the basic constructs of the language, but were less sanguine about their ability to put the constructs together in an effective manner. Thus began my attempt to formulate short, specific, easy-to-remember guidelines for effective software development in C++: a summary of the things that experienced C++ programmers either almost always do or almost always avoid.

As a computer scientist, I was originally interested in rules that could be checked by a machine. To that end, I outlined a program to examine C++ software for constructs that were "almost always wrong." Currently under development, this checking program has become known as lint++. However, it quickly became apparent that the great majority of the guidelines used by good C++ programmers were too difficult to formalize, or had too many important exceptions, to be blindly enforced by a lint++-like program.

That led me to the notion of something less precise than a computer program but still more focused and to-the-point than a general C++ textbook. The result you now hold in your hands: a book containing 50 specific suggestions on how to improve your C++ programs and designs.

In this book you'll find advice on what you should do, and why, and what you should not do, and why not. Fundamentally, of course, the whys are much more important than the whats, but from a purely pragmatic point of view, it is much more convenient to have a listofguidelines in front of you than it is to memorize a textbook or two. Unlike most books on C++, my presentation here is not organized around particular language features. That is, I don't talk about constructors in one place, aboutvirtual functions in another, about inheritance in a third, etc. Instead, each explanation is tightly coupled to the specific guideline it accompanies, and my coverage of the various aspects of a particular feature is typically dispersed throughout the book.

The advantage of this approach is that it better reflects the complexity of the software systems for which C++ is often chosen, systems in which the understanding of individual language features is not enough. For example, experienced C++ developers know that understanding inline functions and understanding virtual destructors does not necessarily mean that you understand inline virtual destructors. Such battle-scarred developers recognize that comprehending the interactions between the features in C++ is of the greatest possible importance in using the language effectively. The organization of this book reflects that fundamental truth.

The disadvantage of my approach is that you may have to look in more than one place to discover everything I have to say about a particular construct in C++. To minimize the inconvenience inherent in this approach, I have sprinkled cross-references liberally throughout the text, and a comprehensive index is provided at the end of the book.

The set of guidelines in this book is far from exhaustive, but coming up with good rules - ones that are applicable to almost all applications almost all the time - is harder than it looks. Perhaps you know of additional guidelines, of more ways in which to program effectively in C++. If so, I would be delighted to hear about them.

On the other hand, you may feel that some of the items in this book are inappropriate as general advice; that there is a better way to accomplish a task examined in the book; or that one or more of the technical discussions is unclear, incomplete, or misleading. I encourage you to let me know about these things, too.

Donald Knuth has a long history of offering a small reward for people who notify him of errors in his books. The quest for a perfect book is laudable in any case, but in view of the number of bug-ridden C++ books that have been rushed to market, I feel especially strongly compelled to follow Knuth's example. Therefore, for each error in this book that is reported to me - be it technical, grammatical, typographical, or otherwise - I will, in future printings, gladly acknowledge the first person to report that error.

Send your suggested guidelines, your comments, your criticisms, and - sigh - your bug reports to:

Scott Meyersc/o Editor-in-Chief, Corporate and Professional Publishing
Addison-Wesley Publishing Company
1 Jacob Way
Reading, MA 01867
U. S. A.

Alternatively, you may send electronic mail to johnw@aw.com.

I maintain a list of changes to this book since its first printing, including bug-fixes, clarifications, and technical updates. This list is available via anonymous FTP from the Internet site ftp.aw.com in the directory cp/ec++. If you would like a copy of this file, but you lack access to the Internet, please send a request to one of the addresses above, and I will see that the list is sent to you.

Scott Douglas Meyers
Providence, RI
November 1991

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)