Bjarne stroustrup's advice to C ++ programmers

Source: Internet
Author: User

The C ++ programming language (Special


Chapter 1 to readers
[1] When writing a program, you are creating a specific idea for your solution to a problem.

. Let the program structure reflect these ideas as directly as possible:
[A] If you can think of "it" as an independent concept, you can make it into a class.
[B] If you can regard "it" as an independent entity, you can make it an object of a class.
[C] If two classes have a common interface, make the interface an abstract class.
[D] if the implementation of the two classes has something remarkable in common, let alone these commonalities to form a base class.
[E] If a class is a container of an object, make it a template.
[F] If a function implements an algorithm for a container, it is implemented as a module available to a family of containers.

Board function.
[G] if a group of classes and templates have a logical relationship with each other, put them into a namespace.
[2] When you define a class that does not implement a mathematical object such as a matrix or a complex number, or define

When a low-level location type is like a chain table:
[A] Do not use global data (use members ).
[B] Do not use global functions.
[C] Do not use public data members.
[D] Do not use friends unless [a] or [c] is avoided.
[E] do not place "type fields" in a class; use virtual functions.
[F] Do not use online functions unless the seat effect is significantly optimized.

Chapter 3 C ++ Overview

[1] Don't be afraid. Everything will become clearer over time.
[2] You do not need to write a good C ++ program after knowing all the details of C ++.
[3] pay special attention to programming technologies, rather than language features.

Chapter 2 standard library concepts

[1] Do not try to do everything as you re-invent the wheel; use the database.
[2] do not believe in miracles; understand what your libraries can do, how they are done, and how costly they are.

[3] when you have a choice, you should first select the standard library instead of other libraries.
[4] do not consider the standard library as ideal for everything.
[5] Remember # include the header file of the feature you are using.
[6] Remember, the features of the standard library are defined in the namespace STD.
[7] use string instead of char *.
[8] If you suspect, use a vector that checks the range.
[9] vector <t>, list <t>, and Map <key, value> are better than T.
[10] to add an element to a container, use push_back () or back_insert ().
[11] Use push_back () for the vector instead of realloc ().
[12] Catch Common exceptions in main.

Chapter 1 Types and declarations

[1] maintain a small scope.
[2] do not use the same name in a scope and its peripheral scope.
[3] declare a name in a declaration (only.
[4] short common and local names and long names that are not commonly used and global.
[5] avoid seemingly similar names.
[6] Maintain a Uniform Naming style.
[7] carefully select a name to reflect its meaning rather than the implementation method.
[8] If the internal type used represents a value that may change, use typdef to define a meaningful value for it.

[9] Use typedef as the type definition synonym and use enumeration or class to define a new type.
[10] Remember that each declaration must describe a type (no implicit INT ).
[11] avoid unnecessary assumptions about character values.
[12] avoid unnecessary assumptions about the integer size.
[13] avoid unnecessary assumptions about the range of floating point types.
[14] General int instead of short Int or long int is preferred.
[15] Double instead of float or long double is preferred.
[16] General char instead of signed Char or unsigned char is preferred.
[17] avoid unnecessary assumptions about object size.
[18] avoid unsigned arithmetic.
[19] consider the conversion from signed to unsigned or from unsigned to singed with questions.
[20] You should look at the conversion from floating point to integer with questions.
[21] You should look at the conversion to a smaller type with doubts, such as converting an int to a char.

Chapter 2 pointers, arrays, and structures

[1] avoid non-trivial pointer arithmetic.
[2] Be careful not to write beyond the limits of the function.
[3] Try to use 0 instead of null.
[4] Use Vector and valarrray instead of an internal (c-style) array.
[5] Try to use a string instead of a char array ending with 0.
[6] use as few common referenced parameters as possible.
[7] avoid void * except for some low-level proxies.
[8] avoid using non-trivial texts ("mysterious number") in the code "). Instead, define and use

Symbol constants.

Chapter 1 expressions and statements

[1] Try to use a standard library instead of other libraries and "manually created code ".
[2] avoid overly complex expressions.
[3] If you have doubts about the operator's priority, enclose brackets.
[4] avoid explicit type conversion.
[5] If explicit type conversion is required, special forced operators are recommended instead of the mandatory C-style operators.
[6] use the T (e) Notation only for well-defined structures.
[7] avoid expressions with undefined order of value.
[8] avoid Goto.
[9] avoid do statements.
[10] do not declare a variable before you initialize it.
[11] annotations are concise, clear, and meaningful.
[12] consistent indent orchestration style.
[13] tends to define a member function operator new () to replace the global operator new ().
[14] when reading input, we should always consider input in a pathological form.

Chapter 2 Functions

[1] Question those non-const reference parameters. If you want a function to modify its parameters, use a pointer.

Or return value.
[2] When you need to minimize parameter replication, you should use const to reference parameters.
[3] Wide and consistent use of Const.
[4] avoid macros.
[5] avoid uncertain number of parameters.
[6] Do not return pointers or references to local variables.
[7] Use overload when some functions perform the same jobs for different types.
[8] When you overload integers, You can provide functions to eliminate common ambiguities.
[9] when using a pointer to a function, consider whether the virtual function or template is a better choice.
[10] If you must use macros, use ugly names with many uppercase letters.

Chapter 2 namespace and exceptions

[1] Use namespace to represent the logical structure.
[2] place a non-local name in a namespace, except main.
[3] namespace design should make it easy for you to use it without visiting other users.

Specify the namespace.
[4] avoid using a short name for a namespace.
[5] if necessary, use the namespace alias to mitigate the impact of a long namespace.
[6] avoid adding too much burden to the user of your namespace.
[7] namespace: Member is used to define a namespace member.
[8] Using namespace is used only during conversion or in a local scope.
[9] use exceptions to relax the connection between "error" processing code and normal processing code.
[10] use a user-defined type as an exception, rather than an internal type.
[11] when the local control structure is sufficient to cope with problems, do not use exceptions.

Chapter 4 source files and programs

[1] Using header files to represent the interface and emphasize the logical structure.
[2] Use # include to include the header file in the source file that implements relevant functions.
[3] do not define global variables with the same name in different compilation units.
[4] avoid defining non-inline functions in the header file.
[5] Use # include only in the global scope or namespace.
[6] Only # include contains the complete definition.
[7] use a protected character.
[8] Use # include to include the C header file to the namespace to avoid global names.
[9] Make the header file self-sufficiency.
[10] differentiate between user interfaces and implementation interfaces.
[11] differentiate between general user interfaces and expert user interfaces.
[12] avoid non-local codes that are intended to be used in non-C ++ components during runtime.


Chapter 1 category

[1] use classes to represent concepts.
[2] Only use public data (struct) when it actually kills the data, and

There is no such thing as a member.
[3] a specific type belongs to the simplest class. If it is useful, use the specific type as much as possible,

Instead of using a more complex Alibaba Cloud or a simple data structure.
[4] only functions that need to be directly represented by the struct class are used as member functions.
[5] namespace is used to clarify the relationship between classes and helper functions.
[6] convert member functions without modifying object values into const member functions.
[7] convert the member functions that need to be represented by the struct class, but do not need to be called for a specific object into static

Member function.
[8] create a class's variant through the constructor.
[9] If a constructor applies for a resource, the Destructor should release a resource.
[10] If there is a pointer member in a class, it requires a copy operation (including copying constructor and copying

Value ).
[11] If a referenced member exists in a class, it may need a copy operation (including the copy constructor and

Copy value assignment ).
[12] If a class requires a copy operation or destructor, most of it also requires constructors, destructor,

Copy the value assignment function and the copy constructor.
[13] You need to check self-assignment in the copy assignment function.
[14] When writing a copy constructor, Please carefully copy each element to be copied (beware of the default initial formula

[15] When adding a new member function to a class, check carefully to see if there is a need to update the function.

User-Defined constructor to enable it to initialize new members.
[16] Use enumeration when you need to define an integer constant in the class declaration.
[17] sequence dependency should be avoided when constructing global and namespace objects.
[18] use the first switch to ease the order dependency problem.
[19] Remember that temporary objects will be destroyed at the end of the complete expression that creates them.

Chapter 4 Operator Overloading

[1] The definition operator is mainly used to simulate Regular usage.
[2] for large computing objects, use const to reference the parameter type.
[3] for large results, consider optimizing the return method.
[4] if the default copy operation is applicable to a class, it is best to use it directly.
[5] if the default copy operation is inappropriate for a class, redefine it or disable it.
[6] for operations that need to be accessed and represented, it is preferred to act as a member function rather than as a non-member function.
[7] for operations that do not access the representation, it is preferred to act as a non-member function rather than a member function.
[8] Using namespaces to associate functions with their classes.
[9] use non-member functions for symmetric operators.
[10] Use () as the subscript of a multi-dimensional array.
[11] only one "size parameter" constructor is used as an explicit function.
[12] for non-special use, it is best to use a standard string instead of your own exercises.
[13] introduce implicit conversions.
[14] use a member function to express operators that require the left value as their left operation object.

Chapter 4 Derived classes

[1] avoid type fields.
[2] Use pointers and references to avoid cutting problems.
[3] using abstract classes to centralize the design to provide a clear interface.
[4] abstract classes are used to minimize the interface size.
[5] exclude implementation details from the interface using abstract classes.
[6] using virtual functions is a new implementation that can be added without affecting user code.
[7] use abstract classes to minimize re-Compilation of user code.
[8] Different implementations of abstract classes can coexist.
[9] a class with virtual functions should have a virtual destructor.
[10] abstract classes do not require constructors.
[11] different concepts are represented differently.

Chapter 4 Template

[1] using templates to describe algorithms that require many parameter types.
[2] use a template to express the container.
[3] provides specialization for pointer containers to reduce code size.
[4] the general form of the template is always declared before the specialization.
[5] declare it before using the specialization.
[6] minimize the dependence of template definitions on the instantiated environment.
[7] define each specialization you declare.
[8] consider whether a template needs to be specialized for C-style strings and arrays.
[9] parameterization with objects expressing policies.
[10] provides a unified interface for different types of implementations with the same concept of specialization and overloading.
[11] provides a simple interface for simple situations, and uses overload and default parameters to express uncommon situations.
[12] exclude program errors on a specific instance before modifying it to a common template.
[13] If the template definition needs to be accessed in other compilation units, remember to write export.
[14] large templates and templates with non-trivial environment dependencies should be compiled separately.
[15] use a template to indicate conversions, but be very careful when defining these conversions.
[16] if necessary, use the constraint () member function to limit the real parameters of the template.
[17] reduces compilation and connection time through explicit instantiation.
[18] If the runtime efficiency is very important, it is best to use a template instead of a derived class.
[19] It is important to add various variants without re-Compiling. It is best to use a derived class instead of a template.
[20] If a public base class cannot be defined, it is best to use a template instead of a derived class.
[21] when the internal types and structures with compatibility constraints are very important, it is best to use a template instead of a derived class.

Chapter 4 Exception Handling

[1] handle errors with exceptions.
[2] Do not use exceptions when more local control agencies are sufficient.
[3] use the "resource application is initialized" technology to manage resources.
[4] Not all American programs require security in case of exceptions.
[5] The "resource application is initialized" technology and exception processor are used to maintain the variant.
[6] use as few try blocks as possible, and use the "resource application is initialized" technology instead of explicit processor code.
[7] Not all functions in the united states need to handle every possible error.
[8] failure indicated by throwing an exception in the constructor.
[9] before an exception is thrown from the assignment, the operation object is in a valid state.
[10] avoid throwing an exception from the destructor.
[11] Let main () capture and report all exceptions.
[12] separating normal and error handling codes.
[13] before throwing an exception in the constructor, ensure that all resources applied for in this constructor are released.
[14] Hierarchical Resource Management.
[15] abnormal description of the main interface.
[16] Be careful that the storage is lost due to an exception in the new allocation.
[17] If a function may throw an exception, it should be assumed that it will throw the exception.
[18] Do not assume that all exceptions are derived from the ion class.
[19] the database should not unilaterally terminate the program. Instead, an exception should be thrown for the caller to make a decision.
[20] the database should not generate error messages for end users. Instead, it should throw an exception for the caller

Make decisions.
[21] An error handling policy was developed before the design.

Chapter 2 class hierarchy

[1] using conventional multi-inheritance to express feature merging.
[2] Using Multi-inheritance to separate details from interfaces.
[3] using a virtual base class to express something that is common to some classes (not all classes) in the class hierarchy.
[4] avoid explicit type conversion (forced ).
[5] Use dynamic_cast where the hierarchy of roaming classes is inevitable.
[6] Use dynamic_cast instead of typeid whenever possible.
[7] Try to use private instead of protected.
[8] do not declare a protected data member.
[9] If a class defines operator Delete (), it should also have a virtual destructor.
[10] Do not call virtual functions during constructor and destructor.
[11] use as few explicit qualifiers as possible to resolve Member names. It is best to use them in the overwrite function.

Chapter 4 database organization and container

[1] use the standard library function to maintain portability.
[2] The features of the standard library must not be defined separately.
[3] never consider a standard database better than anything else.
[4] when defining a new function, consider whether it can be included in the framework provided by the standard library.
[5] Remember that the standard library function is defined in the namespace STD.
[6] do not explicitly declare its functions by including the quasi-card header file.
[7] advantages of subsequent abstraction.
[8] interface to avoid hypertrophy.
[9] It is better to write an algorithm that uses the reverse iterator than to write an explicit loop in reverse order.
[10] extract iterator from reverse_iterator using base.
[11] Passing containers through references.
[12] use the iterator type, such as list <char>: iterator, instead of using the pointer of the index container element.
[13] use the const iterator when you do not need to modify container elements.
[14] if you want to check the access range, use at () directly or indirectly ().
[15] use multiple containers, push_back () or resize (), and use less arrays and realloc ().
[16] After the vector size is changed, do not use the iterator pointing to it.
[17] use reserve () to avoid making the iterator invalid.
[18] When necessary, reserve () can make execution easier to predict.

Chapter 4 standard library container

[1] to use a container, use vector first.
[2] understand the cost of each operation you often use (complexity, large O measurement ).
[3] The container interface, implementation, and representation make different concepts. Do not confuse them.
[4] You can sort and search based on different criteria.
[5] do not use a C-style string as the key code unless you provide an appropriate comparison criterion.
[6] You can define such a comparison criterion to map equivalent but different key code values to the same level.

Key code.
[7] when inserting and deleting elements, the sequence end operation (back operation) is used best ).
[8] When you need to insert and delete many objects in front or middle of the container, use list.
[9] use map or multimap when you access elements through key codes.
[10] use the smallest set of operations to achieve maximum flexibility.
[11] to maintain the sequence of elements, select map instead of hash_map.
[12] If the search speed is extremely important, select hash_map instead of map.
[13] If the element definition cannot be smaller than the operation, select hash_map instead of map.
[14] Use Find () when you need to check whether a key code is in the associated container ().
[15] Use performance_range () to locate all elements with a given key code in the associated container.
[16] multimap is used when multiple values with the same key code need to be in order.
[17] When the key code itself is the value you need to save, use set or Multiset.

Chapter 3 algorithms and function objects

[1] use multiple algorithms and use less loops.
[2] When writing a loop, consider whether it can be expressed as a common algorithm.
[3] routinely repeat the algorithm set to see if the card can make new applications clearer.
[4] ensure that a pair of iterator parameters indeed express a sequence.
[5] The most frequently used operations should be simple and safe during design.
[6] bar testing is expressed as a form that can be used as a predicate.
[7] Remember that predicates are functions and objects, not types.
[8] You can use the constructor to create a one-dimensional predicate from a binary predicate.
[9] Use mem_fun () and mem_fun_ref () to apply the algorithm to containers.
[10] When you need to constrain a parameter to a function, use ptr_fun ().
[11] Remember that srrcmp () uses 0 to indicate "equal", which is different from =.
[12] for_each () and Tranform () are used only when no special algorithms are available ().
[13] Use predicates to use algorithms based on various comparison criteria and equality criteria.
[14] Using predicates and other function objects, the standard algorithm can be used to indicate a wide range of meanings.
[15] operators <and = are rarely used in standard algorithms because of their default meanings on pointers.
[16] algorithms do not directly add or remove elements to or from their parameter sequences.
[17] the smaller and equal predicates used for the same sequence must match each other.
[18] Sometimes sorted sequences are more effective and elegant to use.
[19] qsort () and bsearch () are used only for compatibility purposes ().

Chapter 2 iterator and distributor

[1] When writing an algorithm, try to determine which iterator is needed to provide acceptable efficiency, and (only

) Use the operators supported by this iterator to express the algorithm.
[2] When the given iterator parameter provides more than the minimum support required by the algorithm, reload the algorithm

Provides more efficient implementations.
[3] Use istream_traits to describe an appropriate algorithm for different iterator categories.
[4] Remember to use ++ before accessing istream_iterator and ostream_iterator.
[5] use the plug-in to avoid container overflow.
[6] use additional checks for troubleshooting, which will be deleted only when necessary.
[7] Use ++ P and use less ++.
[8] Use uninitialized storage to improve the algorithm performance of those extended data structures.
[9] use a temporary buffer to Improve the Performance of algorithms that require a temporary data structure.
[10] Think twice before writing your own distributor.
[11] avoid malloc (), free (), realloc () and so on.
[12] You can simulate the template typedef using the technology used for rebind.

Chapter 2 string

[1] use string operations as much as possible, and use less C-style string functions.
[2] using string as a variable or member, not as a base class.
[3] You can use string as the parameter value or return value to let the system care about storage management issues.
[4] When you want to perform a range check, use at () instead of the iterator or [].
[5] When you want to optimize the speed, use an iterator or [] instead of ().
[6] directly or indirectly use substr () to read substrings and use Replace () to write substrings.
[7] using the find () operation to determine the value position in the string (instead of writing an explicit loop ).
[8] When you need to efficiently add characters, please append them after the string.
[9] use string as the character input destination without extreme time requirements.
[10] use string: NPOs to represent the rest of the sring ".
[11] if necessary, use low-level operations to implement strng that is extremely frequently used (instead of using low-level operations everywhere

Data structure ).
[12] If you use string, capture length_error and out_of_rang exceptions in some places,
[13] Be careful not to pass the char * with a value of 0 to the string function.
[14] only when it is necessary (and), c_str () is used to generate the string C style representation.
[15] when you need to know the string category, use functions such as isalpha () and isdigit ().

Write detection of character values.

Chapter 4 stream

[1] when defining a user-defined type value <and>, a clear text expression should be used.
[2] brackets must be used to print expressions containing low-priority operators.
[3] When adding new <and> operators, you do not have to modify istream or ostream.
[4] You can define a function based on the second (or later) parameter.

Such behavior.
[5] Remember to follow the default conventions> skip all spaces.
[6] using low-level input functions (such as get () and read () is mainly used to implement advanced input functions.
[7] Pay Attention to the termination rules when using get (), Getline (), and read.
[8] When controlling I/O, try to use the operator and use fewer status signs.
[9] (only) catch rare I/O errors with exceptions.
[10] linking a stream for interactive I/O.
[11] use a flag to centralize the entry and exit code of many functions in one place.
[12] Do not write parentheses at the end of the parameter-free operator.
[13] Remember to write # include <iomanip> when using a standard operator.
[14] You can get the effect (and efficiency) of a ternary operator by defining a simple function object ).
[15] Remember that the width description applies only to the next I/O operation.
[16] Remember that the precision description is only valid for all subsequent floating point output operations.
[17] use a string stream for memory formatting.
[18] You can describe the mode of a file stream.
[19] when expanding the I/O system, it should be clear that the region is divided into the format (iostream) and the buffer (streambuf)

[20] implement the non-standard mode of transmission value as stream buffer.
[21] convert formatted values to stream operations in a non-standard manner.
[22] You can use a pair of functions to isolate and encapsulate calls to user-defined code.
[23] Before reading, you can use in_avail () to determine whether the input operation will be blocked.
[24] clearly dividing simple operations that require efficiency and operations that implement certain policies (turning the former into an inline

The latter is made virtual ).
[25] Use locale to localize "Cultural Differences.
[26] Use sync_with_stdio (X) to mix C and C ++ I/O, or separate C and C ++

Grid I/O.
[27] Be careful when the C-style I/O type is incorrect.

Chapter 2 values

[1] numerical problems are often and subtle. If you are not 100% sure about the mathematical aspect of the numerical problem, please go

Experts or do experiments.
[2] Use numberic_limits to determine the nature of the internal type.
[3] numberic_limits, which is a user-defined scalar type.
[4] If the running validity rate is more important than the flexibility of operations and elements, use valarray

Perform numerical calculation.
[5] Operations expressed on a part of the array by cutting, rather than loops.
[6] Using aggregators, efficiency is achieved by clearing the temporary amount and better algorithms.
[7] Using STD: complex for plural arithmetic.
[8] You can convert the old code using the complex class to the STR: complex template using a typedef.
[9] before a write loop computes a value from a table, consider accumulate (),

Inner_produce (), partial_sum (), and adjacent_difference ().
[10] it is best to use a random number with a specific distribution, instead of using rand () directly ().
[11] note that your random number is random.

Chapter 2 Development and Design

[1] Know what you are trying to do.
[2] Remember that software development is a human activity.
[3] Using analogy to prove intentional deception.
[4] maintaining a specific real goal.
[5] Do not try to solve social problems in technical ways.
[6] There should be long-term considerations in designing and treating people.
[7] it makes sense to design programs before coding, and there is no lower limit on program scale.
[8] feedback should be encouraged during the design process.
[9] Do not take everything as progress.
[10] do not promote things that exceed your needs, that you already have direct experience, or that you have tested.
[11] describe the concept as a class.
[12] The system also has some properties that should not be expressed using classes.
[13] hierarchical relationships between concepts are represented by class hierarchies.
[14] Take the initiative to look for commonalities between concepts in the application and implementation, and express the resulting general concepts as the basis

[15] classification methods in other fields may not be suitable for the classification of inheritance models in applications.
[16] behavior-based and non-variant design class hierarchy.
[17] Consider use cases.
[18] CRC cards are considered.
[19] using existing systems as the source and starting point of model and inspiration.
[20] Be aware of the importance of visual graphics engineering.
[21] abandon a prototype when it becomes a burden.
[22] designed for change, focus on flexibility, scalability, portability, and reuse.
[23] focus on component design.
[24] Let each interface represent a concept in an abstract level.
[25] Change-oriented design for stability.
[26] The design is stable by minimizing, most common, and abstracting frequently used interfaces.
[27] Keep as small as possible and do not add new features for "special needs.
[28] other representations of classes are always considered. If there cannot be other methods, this class may not represent

A clear concept.
[29] repeated review, refined design and implementation.
[30] use the best tools for debugging and problem analysis, design, and implementation.
[31] conduct tests, analyses and tests as soon as possible and as frequently as possible.
[32] Do not forget the efficiency.
[33] Maintain a standard level suitable for the project scale.
[34] ensure that someone is responsible for the overall design of the project.
[35] documents, recommendations, and support for reusable components.
[36] Write the goal and details into the document.
[37] the teaching materials provided for new developers will be part of the document.
[38] encourage the reuse of designs, libraries, and classes, and reward them.

Chapter 2 design and programming

[1] data abstraction and object-oriented design should be developed.
[2] (only) use the features and technologies of C ++ as needed.
[3] The design should match the programming style.
[4] taking classes/concepts as the most basic focus in design, rather than functions/processing.
[5] use classes to represent concepts.
[6] Using inheritance (only) to represent the hierarchical relationship between concepts.
[7] use static types on the application layer to provide enhanced interface guarantee.
[8] use a program generator and a direct interface operation tool to complete well-defined work.
[9] Do not use program generators or

User Interface tool.
[10] separated abstraction at different levels.
[11] focus on component design.
[12] ensure that virtual functions have a well-defined meaning, and each overwriting function achieves the expected behavior.
[13] The public interface indicates "A" link.
[14] A member represents a "relationship.
[15] it is best to use a direct member to indicate simple inclusion without pointing to a pointer to a separately allocated object.
[16] try to ensure that the dependency is easy to understand, as far as possible, there is no loop, and the minimum.
[17] All classes are well defined.
[18] explicitly expresses the prefix, post condition, and other assertions as assertions (assert () may be used ()).
[19] The defined interface should only expose as little information as possible.
[20] minimize the dependence of one interface on other interfaces.
[21] The interface must be of a strong type.
[22] use the application layer type to express the interface.
[23] express the interface so that requests can be passed to the remote server.
[24] interface for avoiding hypertrophy.
[25] use private data and member functions whenever possible.
[26] use protected/private to distinguish the designer of the derived class from the general user.
[27] Use templates for general program design.
[28] Use templates to parameterize algorithm policies.
[29] If type Parsing is required during compilation, use the template.
[30] If you need to perform type resolution at runtime, use a hierarchy.

Chapter 1 Functions of Classes

[1] You should make a conscious decision on the use of a class (as a designer or user ).
[2] considerations should be noted regarding the trade-offs between classes of different types.
[3] using specific types to represent simple independent concepts.
[4] express the best results and key concepts with specific types.
[5] do not derive from a specific class.
[6] using abstract classes to represent interfaces with objects that may change.
[7] An abstract class is used to represent interfaces with multiple objects indicating coexistence.
[8] use abstract classes to represent New interfaces of existing types.
[9] node classes should be used when similar concepts share many implementation details.
[10] Gradually expand an implementation using node classes.
[11] Get the interface from object with runtime type recognition.
[12] use classes to represent actions with associated status information.
[13] use classes to indicate actions that require storage, transfer, or delayed execution.
[14] use the interface class to adjust a class for a new usage (without modifying this class ).
[15] Add a check using the interface class.
[16] using a handle to avoid direct use of pointers and references.
[17] Using handles to manage shared representations.
[18] use application frameworks in application fields that can pre-define control structures.

Related Article

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: 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.