interface inheritance和implementation inheritance的区别?

wdlius 2002-06-26 11:01:51
今天看C++Builder深度探险,有一句话讲道COM主张的是interface inheritance,而不是implementation inheritance.
不知道这两者有什么区别。
...全文
105 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ajoo 2002-06-29
  • 打赏
  • 举报
回复
Not only COM.
it's the principle of all OOP and OOD.
in OO language,
interface inheritance is also called subtyping.
implementation inheritance is also called subclassing.

subtyping gives loose coupling, flexibility.
subclassing gives tight coupling, more static.
look at the following pseudocode:

interface IA{
void f();
}
interface IB:IA{
void g();
}
class A1:IA{
...
}
class A2:IA{
...
}
class A3:IA{
...
}
NOTE, if we use subclassing to reuse code from A1/A2/A3, then:
class B1:A1, IB{
void g(){...}
}
class B2:A2, IB{
void g(){...}
}
...

see? when you do subclassing, you have to specify which specific implementation class (A1 or A2 or A3?) to inherit.


While if we use interface inheritance:
class B:IB{
void f(){a.f();}
void g(){...}
private final A a;
}

one class B can reuse any one of A1, A2 and A3.
bill_lasker 2002-06-29
  • 打赏
  • 举报
回复
interface inheritance:
接口继承,使得子类的接口与父类一致,即调用方式一致
implementation inheritance
实现继承,使得子类的动作与父类一致
hollysky 2002-06-28
  • 打赏
  • 举报
回复
virtual function map
kiko_lee 2002-06-27
  • 打赏
  • 举报
回复
呵呵,一个是接口继承,一个是执行继承。
一个是接口,一个是执行,不一样哦
Contents Preface v Foreword to the second edition xiii About the accompanying CD-ROM xiv On the bibliography, Internet sources and exercises xv Contents xvii PART A: THE ISSUES 1 Chapter 1: Software quality 3 1.1 EXTERNAL AND INTERNAL FACTORS 3 1.2 A REVIEW OF EXTERNAL FACTORS 4 1.3 ABOUT SOFTWARE MAINTENANCE 17 1.4 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 19 1.5 BIBLIOGRAPHICAL NOTES 19 Chapter 2: Criteria of object orientation 21 2.1 ON THE CRITERIA 21 2.2 METHOD AND LANGUAGE 22 2.3 IMPLEMENTATION AND ENVIRONMENT 31 2.4 LIBRARIES 33 2.5 FOR MORE SNEAK PREVIEW 34 2.6 BIBLIOGRAPHICAL NOTES AND OBJECT RESOURCES 34 PART B: THE ROAD TO OBJECT ORIENTATION 37 Chapter 3: Modularity 39 3.1 FIVE CRITERIA 40 3.2 FIVE RULES 46 3.3 FIVE PRINCIPLES 53 3.4 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 64 3.5 BIBLIOGRAPHICAL NOTES 64 EXERCISES 65CONTENTS xviii Chapter 4: Approaches to reusability 67 4.1 THE GOALS OF REUSABILITY 68 4.2 WHAT SHOULD WE REUSE? 70 4.3 REPETITION IN SOFTWARE DEVELOPMENT 74 4.4 NON-TECHNICAL OBSTACLES 74 4.5 THE TECHNICAL PROBLEM 81 4.6 FIVE REQUIREMENTS ON MODULE STRUCTURES 83 4.7 TRADITIONAL MODULAR STRUCTURES 89 4.8 OVERLOADING AND GENERICITY 93 4.9 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 98 4.10 BIBLIOGRAPHICAL NOTES 99 Chapter 5: Towards object technology 101 5.1 THE INGREDIENTS OF COMPUTATION 101 5.2 FUNCTIONAL DECOMPOSITION 103 5.3 OBJECT-BASED DECOMPOSITION 114 5.4 OBJECT-ORIENTED SOFTWARE CONSTRUCTION 116 5.5 ISSUES 117 5.6 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 119 5.7 BIBLIOGRAPHICAL NOTES 119 Chapter 6: Abstract data types 121 6.1 CRITERIA 122 6.2 IMPLEMENTATION VARIATIONS 122 6.3 TOWARDS AN ABSTRACT VIEW OF OBJECTS 126 6.4 FORMALIZING THE SPECIFICATION 129 6.5 FROM ABSTRACT DATA TYPES TO CLASSES 142 6.6 BEYOND SOFTWARE 147 6.7 SUPPLEMENTARY TOPICS 148 6.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 159 6.9 BIBLIOGRAPHICAL NOTES 160 EXERCISES 161 PART C: OBJECT-ORIENTED TECHNIQUES 163 Chapter 7: The static structure: classes 165 7.1 OBJECTS ARE NOT THE SUBJECT 165 7.2 AVOIDING THE STANDARD CONFUSION 166 7.3 THE ROLE OF CLASSES 169 7.4 A UNIFORM TYPE SYSTEM 171 7.5 A SIMPLE CLASS 172 7.6 BASIC CONVENTIONS 177CONTENTS xix 7.7 THE OBJECT-ORIENTED STYLE OF COMPUTATION 181 7.8 SELECTIVE EXPORTS AND INFORMATION HIDING 191 7.9 PUTTING EVERYTHING TOGETHER 194 7.10 DISCUSSION 203 7.11 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 213 7.12 BIBLIOGRAPHICAL NOTES 215 EXERCISES 216 Chapter 8: The run-time structure: objects 217 8.1 OBJECTS 218 8.2 OBJECTS AS A MODELING TOOL 228 8.3 MANIPULATING OBJECTS AND REFERENCES 231 8.4 CREATION PROCEDURES 236 8.5 MORE ON REFERENCES 240 8.6 OPERATIONS ON REFERENCES 242 8.7 COMPOSITE OBJECTS AND EXPANDED TYPES 254 8.8 ATTACHMENT: REFERENCE AND VALUE SEMANTICS 261 8.9 DEALING WITH REFERENCES: BENEFITS AND DANGERS 265 8.10 DISCUSSION 270 8.11 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 276 8.12 BIBLIOGRAPHICAL NOTES 277 EXERCISES 277 Chapter 9: Memory management 279 9.1 WHAT HAPPENS TO OBJECTS 279 9.2 THE CASUAL APPROACH 291 9.3 RECLAIMING MEMORY: THE ISSUES 293 9.4 PROGRAMMER-CONTROLLED DEALLOCATION 294 9.5 THE COMPONENT-LEVEL APPROACH 297 9.6 AUTOMATIC MEMORY MANAGEMENT 301 9.7 REFERENCE COUNTING 302 9.8 GARBAGE COLLECTION 304 9.9 PRACTICAL ISSUES OF GARBAGE COLLECTION 309 9.10 AN ENVIRONMENT WITH MEMORY MANAGEMENT 312 9.11 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 315 9.12 BIBLIOGRAPHICAL NOTES 315 EXERCISES 316 Chapter 10: Genericity 317 10.1 HORIZONTAL AND VERTICAL TYPE GENERALIZATION 317 10.2 THE NEED FOR TYPE PARAMETERIZATION 318 10.3 GENERIC CLASSES 320CONTENTS xx 10.4 ARRAYS 325 10.5 THE COST OF GENERICITY 328 10.6 DISCUSSION: NOT DONE YET 329 10.7 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 329 10.8 BIBLIOGRAPHICAL NOTES 330 EXERCISES 330 Chapter 11: Design by Contract: building reliable software 331 11.1 BASIC RELIABILITY MECHANISMS 332 11.2 ABOUT SOFTWARE CORRECTNESS 333 11.3 EXPRESSING A SPECIFICATION 334 11.4 INTRODUCING ASSERTIONS INTO SOFTWARE TEXTS 337 11.5 PRECONDITIONS AND POSTCONDITIONS 338 11.6 CONTRACTING FOR SOFTWARE RELIABILITY 341 11.7 WORKING WITH ASSERTIONS 348 11.8 CLASS INVARIANTS 363 11.9 WHEN IS A CLASS CORRECT? 369 11.10 THE ADT CONNECTION 373 11.11 AN ASSERTION INSTRUCTION 378 11.12 LOOP INVARIANTS AND VARIANTS 380 11.13 USING ASSERTIONS 389 11.14 DISCUSSION 398 11.15 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 406 11.16 BIBLIOGRAPHICAL NOTES 407 EXERCISES 408 POSTSCRIPT: THE ARIANE 5 FAILURE 410 Chapter 12: When the contract is broken: exception handling 411 12.1 BASIC CONCEPTS OF EXCEPTION HANDLING 411 12.2 HANDLING EXCEPTIONS 414 12.3 AN EXCEPTION MECHANISM 419 12.4 EXCEPTION HANDLING EXAMPLES 422 12.5 THE TASK OF A RESCUE CLAUSE 427 12.6 ADVANCED EXCEPTION HANDLING 431 12.7 DISCUSSION 435 12.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 437 12.9 BIBLIOGRAPHICAL NOTES 438 EXERCISES 438 Chapter 13: Supporting mechanisms 439 13.1 INTERFACING WITH NON-O-O SOFTWARE 439 13.2 ARGUMENT PASSING 444CONTENTS xxi 13.3 INSTRUCTIONS 447 13.4 EXPRESSIONS 452 13.5 STRINGS 456 13.6 INPUT AND OUTPUT 457 13.7 LEXICAL CONVENTIONS 457 13.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 458 EXERCISES 458 Chapter 14: Introduction to inheritance 459 14.1 POLYGONS AND RECTANGLES 460 14.2 POLYMORPHISM 467 14.3 TYPING FOR INHERITANCE 472 14.4 DYNAMIC BINDING 480 14.5 DEFERRED FEATURES AND CLASSES 482 14.6 REDECLARATION TECHNIQUES 491 14.7 THE MEANING OF INHERITANCE 494 14.8 THE ROLE OF DEFERRED CLASSES 500 14.9 DISCUSSION 507 14.10 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 516 14.11 BIBLIOGRAPHICAL NOTES 517 EXERCISES 517 Chapter 15: Multiple inheritance 519 15.1 EXAMPLES OF MULTIPLE INHERITANCE 519 15.2 FEATURE RENAMING 535 15.3 FLATTENING THE STRUCTURE 541 15.4 REPEATED INHERITANCE 543 15.5 DISCUSSION 563 15.6 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 566 15.7 BIBLIOGRAPHICAL NOTES 567 EXERCISES 567 Chapter 16: Inheritance techniques 569 16.1 INHERITANCE AND ASSERTIONS 569 16.2 THE GLOBAL INHERITANCE STRUCTURE 580 16.3 FROZEN FEATURES 583 16.4 CONSTRAINED GENERICITY 585 16.5 ASSIGNMENT ATTEMPT 591 16.6 TYPING AND REDECLARATION 595 16.7 ANCHORED DECLARATION 598 16.8 INHERITANCE AND INFORMATION HIDING 605 16.9 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 609CONTENTS xxii 16.10 BIBLIOGRAPHICAL NOTE 610 EXERCISES 610 Chapter 17: Typing 611 17.1 THE TYPING PROBLEM 611 17.2 STATIC TYPING: WHY AND HOW 615 17.3 COVARIANCE AND DESCENDANT HIDING 621 17.4 FIRST APPROACHES TO SYSTEM VALIDITY 628 17.5 RELYING ON ANCHORED TYPES 630 17.6 GLOBAL ANALYSIS 633 17.7 BEWARE OF POLYMORPHIC CATCALLS! 636 17.8 AN ASSESSMENT 639 17.9 THE PERFECT FIT 640 17.10 KEY CONCEPTS STUDIED IN THIS CHAPTER 641 17.11 BIBLIOGRAPHICAL NOTES 641 Chapter 18: Global objects and constants 643 18.1 CONSTANTS OF BASIC TYPES 643 18.2 USE OF CONSTANTS 645 18.3 CONSTANTS OF CLASS TYPES 646 18.4 APPLICATIONS OF ONCE ROUTINES 648 18.5 CONSTANTS OF STRING TYPE 653 18.6 UNIQUE VALUES 654 18.7 DISCUSSION 656 18.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 659 18.9 BIBLIOGRAPHICAL NOTES 660 EXERCISES 660 PART D: OBJECT-ORIENTED METHODOLOGY: APPLYING THE METHOD WELL 661 Chapter 19: On methodology 663 19.1 SOFTWARE METHODOLOGY: WHY AND WHAT 663 19.2 DEVISING GOOD RULES: ADVICE TO THE ADVISORS 664 19.3 ON USING METAPHORS 671 19.4 THE IMPORTANCE OF BEING HUMBLE 673 19.5 BIBLIOGRAPHICAL NOTES 674 EXERCISES 674 Chapter 20: Design pattern: multi-panel interactive systems 675 20.1 MULTI-PANEL SYSTEMS 675 20.2 A SIMPLE-MINDED ATTEMPT 677CONTENTS xxiii 20.3 A FUNCTIONAL, TOP-DOWN SOLUTION 678 20.4 A CRITIQUE OF THE SOLUTION 682 20.5 AN OBJECT-ORIENTED ARCHITECTURE 684 20.6 DISCUSSION 693 20.7 BIBLIOGRAPHICAL NOTE 694 Chapter 21: Inheritance case study: “undo” in an interactive system 695 21.1 PERSEVERARE DIABOLICUM 695 21.2 FINDING THE ABSTRACTIONS 699 21.3 MULTI-LEVEL UNDO-REDO 704 21.4 IMPLEMENTATION ASPECTS 707 21.5 A USER INTERFACE FOR UNDOING AND REDOING 711 21.6 DISCUSSION 712 21.7 BIBLIOGRAPHICAL NOTES 715 EXERCISES 715 Chapter 22: How to find the classes 719 22.1 STUDYING A REQUIREMENTS DOCUMENT 720 22.2 DANGER SIGNALS 726 22.3 GENERAL HEURISTICS FOR FINDING CLASSES 731 22.4 OTHER SOURCES OF CLASSES 735 22.5 REUSE 740 22.6 THE METHOD FOR OBTAINING CLASSES 741 22.7 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 743 22.8 BIBLIOGRAPHICAL NOTES 744 Chapter 23: Principles of class design 747 23.1 SIDE EFFECTS IN FUNCTIONS 748 23.2 HOW MANY ARGUMENTS FOR A FEATURE? 764 23.3 CLASS SIZE: THE SHOPPING LIST APPROACH 770 23.4 ACTIVE DATA STRUCTURES 774 23.5 SELECTIVE EXPORTS 796 23.6 DEALING WITH ABNORMAL CASES 797 23.7 CLASS EVOLUTION: THE OBSOLETE CLAUSE 802 23.8 DOCUMENTING A CLASS AND A SYSTEM 803 23.9 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 806 23.10 BIBLIOGRAPHICAL NOTES 806 EXERCISES 807CONTENTS xxiv Chapter 24: Using inheritance well 809 24.1 HOW NOT TO USE INHERITANCE 809 24.2 WOULD YOU RATHER BUY OR INHERIT? 812 24.3 AN APPLICATION: THE HANDLE TECHNIQUE 817 24.4 TAXOMANIA 820 24.5 USING INHERITANCE: A TAXONOMY OF TAXONOMY 822 24.6 ONE MECHANISM, OR MORE? 833 24.7 SUBTYPE INHERITANCE AND DESCENDANT HIDING 835 24.8 IMPLEMENTATION INHERITANCE 844 24.9 FACILITY INHERITANCE 847 24.10 MULTIPLE CRITERIA AND VIEW INHERITANCE 851 24.11 HOW TO DEVELOP INHERITANCE STRUCTURES 858 24.12 A SUMMARY VIEW: USING INHERITANCE WELL 862 24.13 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 863 24.14 BIBLIOGRAPHICAL NOTES 863 24.15 APPENDIX: A HISTORY OF TAXONOMY 864 EXERCISES 869 Chapter 25: Useful techniques 871 25.1 DESIGN PHILOSOPHY 871 25.2 CLASSES 872 25.3 INHERITANCE TECHNIQUES 873 Chapter 26: A sense of style 875 26.1 COSMETICS MATTERS! 875 26.2 CHOOSING THE RIGHT NAMES 879 26.3 USING CONSTANTS 884 26.4 HEADER COMMENTS AND INDEXING CLAUSES 886 26.5 TEXT LAYOUT AND PRESENTATION 891 26.6 FONTS 900 26.7 BIBLIOGRAPHICAL NOTES 901 EXERCISES 902 Chapter 27: Object-oriented analysis 903 27.1 THE GOALS OF ANALYSIS 903 27.2 THE CHANGING NATURE OF ANALYSIS 906 27.3 THE CONTRIBUTION OF OBJECT TECHNOLOGY 907 27.4 PROGRAMMING A TV STATION 907 27.5 EXPRESSING THE ANALYSIS: MULTIPLE VIEWS 914 27.6 ANALYSIS METHODS 917 27.7 THE BUSINESS OBJECT NOTATION 919 27.8 BIBLIOGRAPHY 922CONTENTS xxv Chapter 28: The software construction process 923 28.1 CLUSTERS 923 28.2 CONCURRENT ENGINEERING 924 28.3 STEPS AND TASKS 926 28.4 THE CLUSTER MODEL OF THE SOFTWARE LIFECYCLE 926 28.5 GENERALIZATION 928 28.6 SEAMLESSNESS AND REVERSIBILITY 930 28.7 WITH US, EVERYTHING IS THE FACE 933 28.8 KEY CONCEPTS COVERED IN THIS CHAPTER 934 28.9 BIBLIOGRAPHICAL NOTES 934 Chapter 29: Teaching the method 935 29.1 INDUSTRIAL TRAINING 935 29.2 INTRODUCTORY COURSES 937 29.3 OTHER COURSES 941 29.4 TOWARDS A NEW SOFTWARE PEDAGOGY 942 29.5 AN OBJECT-ORIENTED PLAN 946 29.6 KEY CONCEPTS STUDIED IN THIS CHAPTER 948 29.7 BIBLIOGRAPHICAL NOTES 948 PART E: ADVANCED TOPICS 949 Chapter 30: Concurrency, distribution, client-server and the Internet 951 30.1 A SNEAK PREVIEW 951 30.2 THE RISE OF CONCURRENCY 953 30.3 FROM PROCESSES TO OBJECTS 956 30.4 INTRODUCING CONCURRENT EXECUTION 964 30.5 SYNCHRONIZATION ISSUES 977 30.6 ACCESSING SEPARATE OBJECTS 982 30.7 WAIT CONDITIONS 990 30.8 REQUESTING SPECIAL SERVICE 998 30.9 EXAMPLES 1003 30.10 TOWARDS A PROOF RULE 1022 30.11 A SUMMARY OF THE MECHANISM 1025 30.12 DISCUSSION 1028 30.13 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 1032 30.14 BIBLIOGRAPHICAL NOTES 1033 EXERCISES 1035CONTENTS xxvi Chapter 31: Object persistence and databases 1037 31.1 PERSISTENCE FROM THE LANGUAGE 1037 31.2 BEYOND PERSISTENCE CLOSURE 1039 31.3 SCHEMA EVOLUTION 1041 31.4 FROM PERSISTENCE TO DATABASES 1047 31.5 OBJECT-RELATIONAL INTEROPERABILITY 1048 31.6 OBJECT-ORIENTED DATABASE FUNDAMENTALS 1050 31.7 O-O DATABASE SYSTEMS: EXAMPLES 1055 31.8 DISCUSSION: BEYOND O-O DATABASES 1058 31.9 KEY CONCEPTS STUDIED IN THIS CHAPTER 1060 31.10 BIBLIOGRAPHICAL NOTES 1061 EXERCISES 1062 Chapter 32: Some O-O techniques for graphical interactive applications 1063 32.1 NEEDED TOOLS 1064 32.2 PORTABILITY AND PLATFORM ADAPTATION 1066 32.3 GRAPHICAL ABSTRACTIONS 1068 32.4 INTERACTION MECHANISMS 1071 32.5 HANDLING THE EVENTS 1072 32.6 A MATHEMATICAL MODEL 1076 32.7 BIBLIOGRAPHICAL NOTES 1076 PART F: APPLYING THE METHOD IN VARIOUS LANGUAGES AND ENVIRONMENTS 1077 Chapter 33: O-O programming and Ada 1079 33.1 A BIT OF CONTEXT 1079 33.2 PACKAGES 1081 33.3 A STACK IMPLEMENTATION 1081 33.4 HIDING THE REPRESENTATION: THE PRIVATE STORY 1085 33.5 EXCEPTIONS 1088 33.6 TASKS 1091 33.7 FROM ADA TO ADA 95 1092 33.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 1097 33.9 BIBLIOGRAPHICAL NOTES 1097 EXERCISES 1098CONTENTS xxvii Chapter 34: Emulating object technology in non-O-O environments 1099 34.1 LEVELS OF LANGUAGE SUPPORT 1099 34.2 OBJECT-ORIENTED PROGRAMMING IN PASCAL? 1100 34.3 FORTRAN 1102 34.4 OBJECT-ORIENTED PROGRAMMING AND C 1106 34.5 BIBLIOGRAPHICAL NOTES 1112 EXERCISES 1112 Chapter 35: Simula to Java and beyond: major O-O languages and environments 1113 35.1 SIMULA 1113 35.2 SMALLTALK 1126 35.3 LISP EXTENSIONS 1130 35.4 C EXTENSIONS 1131 35.5 JAVA 1136 35.6 OTHER O-O LANGUAGES 1137 35.7 BIBLIOGRAPHICAL NOTES 1138 EXERCISES 1139 PART G: DOING IT RIGHT 1141 Chapter 36: An object-oriented environment 1143 36.1 COMPONENTS 1143 36.2 THE LANGUAGE 1144 36.3 THE COMPILATION TECHNOLOGY 1144 36.4 TOOLS 1148 36.5 LIBRARIES 1150 36.6 INTERFACE MECHANISMS 1152 36.7 BIBLIOGRAPHICAL NOTES 1160 Epilogue, In Full Frankness Exposing the Language 1161
译序 vii 中英简繁术语对照 ix 目录 xvii 序言 xxi 致谢 xxiii 导读 1. 让自己习惯c++ accustoming yourself to c++ 条款01:视c++ 为一个语言联邦 view c++ as a federation of languages 条款02:尽量以const, enum, inline替换 #define prefer consts,enums, and inlines to #defines. 条款03:尽可能使用const use const whenever possible. 条款04:确定对象被使用前已先被初始化 make sure that objects are initialized before they're used. 2. 构造/析构/赋值运算 constructors, destructors, and assignment operators 条款05:了解c++ 默默编写并调用哪些函数 know what functions c++ silently writes and calls. 条款06:若不想使用编译器自动生成的函数,就该明确拒绝 explicitly disallow the use of compiler-generated functions you do not want. 条款07:为多态基类声明virtual析构函数 declare destructors virtual in polymorphic base classes. 条款08:别让异常逃离析构函数 prevent exceptions from leaving destructors. 条款09:绝不在构造和析构过程中调用virtual函数 never call virtual functions during construction or destruction. 条款10:令operator= 返回一个reference to *this have assignment operators return a reference to *this. 条款11:在operator= 中处理“自我赋值” handle assignment to self in operator=. 条款12:复制对象时勿忘其每一个成分 copy all parts of an object. 3. 资源管理 resource management 条款13:以对象管理资源 use objects to manage resources. 条款14:在资源管理类中小心coping行为 think carefully about copying behavior in resource-managing classes. 条款15:在资源管理类中提供对原始资源的访问 provide access to raw resources in resource-managing classes. 条款16:成对使用new和delete时要采取相同形式 use the same form in corresponding uses of new and delete. 条款17:以独立语句将newed对象置入智能指针 store newed objects in smart pointers in standalone statements. 4. 设计与声明 designs and declarations 条款18:让接口容易被正确使用,不易被误用 make interfaces easy to use correctly and hard to use incorrectly. 条款19:设计class犹如设计type treat class design as type design. 条款20:宁以pass-by-reference-to-const替换pass-by-value prefer pass-by-reference-to-const to pass-by-value. 条款21:必须返回对象时,别妄想返回其reference don't try to return a reference when you must return an object. 条款22:将成员变量声明为private declare data members private. 条款23:宁以non-member、non-friend替换member函数 prefer non-member non-friend functions to member functions. 条款24:若所有参数皆需类型转换,请为此采用non-member函数 declare non-member functions when type conversions should apply to all parameters. 条款25:考虑写出一个不抛异常的swap函数 consider support for a non-throwing swap. 5. 实现 implementations 条款26:尽可能延后变量定义式的出现时间 postpone variable definitions as long as possible. 条款27:尽量少做转型动作 minimize casting. 条款28:避免返回handles指向对象内部成分 avoid returning “handles” to object internals. 条款29:为“异常安全”而努力是值得的 strive for exception-safe code. 条款30:透彻了解inlining的里里外外 understand the ins and outs of inlining. 条款31:将文件间的编译依存关系降至最低 minimize compilation dependencies between files. 6. 继承与面向对象设计 inheritance and object-oriented design 条款32:确定你的public继承塑模出is-a关系 make sure public inheritance models “is-a.” 条款33:避免遮掩继承而来的名称 avoid hiding inherited names. 条款34:区分接口继承和实现继承 differentiate between inheritance of interface and inheritance of implementation. 条款35:考虑virtual函数以外的其他选择 consider alternatives to virtual functions. 条款36:绝不重新定义继承而来的non-virtual函数 never redefine an inherited non-virtual function. 条款37:绝不重新定义继承而来的缺省参数值 never redefine a function's inherited default parameter value. 条款38:通过复合塑模出has-a或“根据某物实现出” model “has-a” or “is-implemented-in-terms-of” through composition. 条款39:明智而审慎地使用private继承 use private inheritance judiciously. 条款40:明智而审慎地使用多重继承 use multiple inheritance judiciously. 7. 模板与泛型编程 templates and generic programming 条款41:了解隐式接口和编译期多态 understand implicit interfaces and compile-time polymorphism. 条款42:了解typename的双重意义 understand the two meanings of typename. 条款43:学习处理模板化基类内的名称 know how to access names in templatized base classes. 条款44:将与参数无关的代码抽离templates factor parameter-independent code out of templates. 条款45:运用成员函数模板接受所有兼容类型 use member function templates to accept “all compatible types.” 条款46:需要类型转换时请为模板定义非成员函数 define non-member functions inside templates when type conversions are desired. 条款47:请使用traits classes表现类型信息 use traits classes for information about types. 条款48:认识template元编程 be aware of template metaprogramming. 8. 定制new和delete customizing new and delete 条款49:了解new-handler的行为 understand the behavior of the new-handler. 条款50:了解new和delete的合理替换时机 understand when it makes sense to replace new and delete. 条款51:编写new和delete时需固守常规 adhere to convention when writing new and delete. 条款52:写了placement new也要写placement delete write placement delete if you write placement new. 9. 杂项讨论 miscellany 条款53:不要轻忽编译器的警告 pay attention to compiler warnings. 条款54:让自己熟悉包括tr1在内的标准程序库 familiarize yourself with the standard library, including tr1. 条款55:让自己熟悉boost familiarize yourself with boost. a 本书之外 b 新旧版条款对映 索引
ModelMaker Code Explorer: Delphi Refactoring made easy! As a Class Browser it shows classes (inheritance) and members (fields, methods, properties) in two filtered views, similar to the windows explorer. On the left the Explorer docked in the IDE editor. The Classes view (top) displays classes and inheritance relations for the current module. The Members view (bottom) show the filtered members for the selected class.Integrated with CodeGear Delphi 5 6 7 and Delphi 2005 2006 2007 2009 and 2010. Navigation features like Member search bar Member Favorites Navigation history help finding your way around in code. Code Explorer is fully Form Designer aware and, for example, has a special filter to suppress component fields and event handler methods. As a Refactoring Editor, it makes changing code easy and fast: Classes and members can be created and modified through drag and drop or by selecting options in dedicated dialogs. You to Refactor, edit, correct and delete existing classes and members just as easy as you created them. Cut,Copy and Paste let you pick up a class, properties and methods and duplicate them or move them to another class or module. Where necessary names and modifiers are automatically adjusted. Drag and Drop Members on a class to copy / move / convert them. For example: Drag interface members on a class to implement the interface (C#, pascal), Drag a module or local procedure on a class to convert it to a method (pascal) Use Editor Refactoring抯 to refactor an entity at cursor position or operate on selected code. For example press Ctrl Shift X to invoke Extract Method for the selected code. Configurable keyboard shortcuts make these refactoring-s available with just one keystroke. Common tasks like Add a Field, Modify a Property and Rename Local are all invoked with just one keystroke. Check a demo movie Beyond Templates demo movie with some editor enhancements. Advanced Code Sort and Rearrange features include: * Rearrange members in Members view using Drag and Drop in Interface and Implementation (pascal) rearrange modes. * Rearrange class members using predefined sorting schemes. * Sort class members according the customizable default scheme. * Sorting maintains Source Regions and optionally sorts inside regions * Sorting hints are emitted for classes not matching the default sorting scheme.

1,265

社区成员

发帖
与我相关
我的任务
社区描述
软件工程/管理 管理版
社区管理员
  • 研发管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧