[Translation] Objective C ++, 3rd edition, Chapter 5. Implementation

Source: Internet
Author: User

Chapter 5. Implementation

By Scott Meyers

Translator: fatalerror99 (itepub's nirvana)

Release: http://blog.csdn.net/fatalerror99/

To a large extent, you can provide appropriate definitions for your classes (and class templates (class templates) and your functions (and function templates (function templates )) providing appropriate declarations is a key part of the battle. As long as you get the correct results, the corresponding implementation is straightforward to a large extent. But there are still some precautions to be careful. Defining variables too early will drag down performance. Excessive use of casts (forced transformation) can lead to slow, difficult to maintain, and code plagued by subtle bugs. Returning the handles (handle) of an internal component of an object will destroy the encapsulation (encapsulation) and leave the dangling handles (empty handle) to the customer. Ignoring the impact of exceptions (Exceptions) may cause leaked resources (leakage of resources) and upted data structures (damage to data structures ). Excessive inlining may cause code bloat ). Excessive coupling may lead to an unacceptable long construction time.

All these problems can be avoided. This chapter describes how to solve them.

This chapter includes the following content. Click to open it:

Item 26: postpone variable definitions as long as possible.

Item 27: Minimize casting.

Item 28: avoid returning "handles" to object internals.

Item 29: Strive for exception-safe code.

Item 30: Understand the ins and outs of inlining.

Item 31: Minimize compilation dependencies between files.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.