Back to Basics: Designing Classes (part 1 of 2)
Back to Basics Designing Classes (part 1 of 2) Klaus Iglberger, CppCon 2021 klaus.iglberger@gmx.de2 Klaus Iglberger C++ Trainer/Consultant Author of the C++ math library (Co-)Organizer Beck, TDD by Example)The Challenge of Class Design 10 Guideline: Design classes for easy change. Guideline: Design classes for easy extensions.Design Guidelines 11 Back to Basics: Class Design (Part ) const; 23 Using inheritance naively to solve our problem easily leads to … … many derived classes; … ridiculous class names; … deep inheritance hierarchies; … duplication between similar implementations0 码力 | 87 页 | 5.64 MB | 5 月前3Back to Basics: Designing Classes (part 2 of 2)
Back to Basics Designing Classes (part 1 of 2) Klaus Iglberger, CppCon 2021 klaus.iglberger@gmx.de2 Klaus Iglberger C++ Trainer/Consultant Author of the C++ math library (Co-)Organizer duplication to enable you to change everything in one place (the DRY principle). Guideline: Design classes for easy change.Data Member Initialization 24 struct Widget { Widget() : Widget(42) // Decisions 63 Guideline: Encapsulate design decisions (i.e. variation points). Guideline: Design classes for easy change.Qualified/Modified Member Data 64 Back to Basics: Class Design (Part 1) The Challenge0 码力 | 76 页 | 2.60 MB | 5 月前3COMPOSABLE C++
DEANE / CPPCON 2021 CPPCON 2021 @ben_deane @ben_deaneIN THIS TALK IN THIS TALK 1. Composability de�ned 2. Composable types 3. Objects and patterns 4. Composability at compile time 5. Hierarchies and log_sink classes: classes:CASE STUDY: LOGGING CASE STUDY: LOGGING Given the Given the push push function, we can write various function, we can write various log_sink log_sink classes: classes: "ordinary" push push function, we can write various function, we can write various log_sink log_sink classes: classes: "ordinary" sinks that send entries to di�erent places (�le, output window, etc) a �lter sink0 码力 | 124 页 | 8.28 MB | 5 月前3Back to Basics: Object-Oriented Programming
https://AndreasFertig.com post@AndreasFertig.com 3Training services ■ I’m available for inhouse classes, onsite or remote. ■ You can also book my course at the CppCon Academy. ■ Or one of my fellow instructors post@AndreasFertig.com 5A class ■ C++ adds classes for object-oriented programming. ■ The constructors B are called when the object is cre- ated. ■ Data fields of classes should be initialized in the constructor initialization list C . ■ The body of the constructor D is available for further opera- tions. ■ Classes can consist of member functions E and data fields G with different access rights A . ■ For everyone:0 码力 | 20 页 | 1.04 MB | 5 月前3Some Things C++ Does Right
C++ DOES RIGHT Patrice Roy Patrice.Roy@USherbrooke.ca; Patrice.Roy@clg.qc.ca CeFTI, Université de Sherbrooke; Collège Lionel-GroulxWho am I? • Father of five (four girls, one boy), ages 25 to 7 • things • CAE Electronics Ltd, IREQ • Full-time teacher since1998 • Collège Lionel-Groulx, Université de Sherbrooke • Works a lot with game programmers • Incidentally, WG21 and WG23 member (although I’ve • There once was a vogue of « everything should be in a class or in an object » • Think about classes that only exist to expose a main entrypoint to a program 110The beauty of (free) functions •0 码力 | 228 页 | 2.47 MB | 5 月前3Conan 1.42 Documentation
def build(self): # Responsible for␣ ˓→invoking the build system cmake = CMake(self) # Helper classes␣ ˓→are available for several build systems ... self.run("bin/unittests") # Run unit tests␣ ˓→compiled Downloaded zlib/1.2.11 from 'conancenter' - Downloaded Packages bzip2/1.0.8:5be2b7a2110ec8acdbf9a1cea9de5d60747edb34 - Download expat/2.2.9:6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7 - Download openssl/1.1 that an existing build script is simultaneously building binaries for different configurations, like de- bug/release, or different architectures (32/64bits), or library types (shared/static). If such a build0 码力 | 841 页 | 7.12 MB | 1 年前3Conan 1 Documentation
For example, you have a package named myssl and you want to generate a Findmyssl.cmake module that de- clares the target MySSL::SSL, but for config mode you want to declare the target MySSL without namespaces runtime_type: Debug compiler.version: 193 os: Windows options shared: True d62dff20d86436b9c58ddc0162499d197be9de1e ... 2.2. Commands 29 Conan Documentation, Release 1.64.1 conan remote login This is the substitute Downloaded zlib/1.2.11 from 'conancenter' - Downloaded Packages bzip2/1.0.8:5be2b7a2110ec8acdbf9a1cea9de5d60747edb34 - Download expat/2.2.9:6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7 - Download openssl/1.10 码力 | 975 页 | 8.75 MB | 1 年前3Conan 1.36 Documentation
Downloaded zlib/1.2.11 from 'conan-center' - Downloaded Packages bzip2/1.0.8:5be2b7a2110ec8acdbf9a1cea9de5d60747edb34 - Download expat/2.2.9:6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7 - Download openssl/1.1 that an existing build script is simultaneously building binaries for different configurations, like de- bug/release, or different architectures (32/64bits), or library types (shared/static). If such a build }, "1": { "ref": "pkga/0.1@user/testing", "options": "", "package_id": "4024617540c4f240a6a5e8911b0de9ef38a11a72", "prev": "0", "context": "host" } }, "revisions_enabled": false }, "version": "0.4"0 码力 | 765 页 | 5.71 MB | 1 年前3Conan 1.40 Documentation
def build(self): # Responsible for␣ ˓→invoking the build system cmake = CMake(self) # Helper classes␣ ˓→are available for several build systems ... self.run("bin/unittests") # Run unit tests␣ ˓→compiled Downloaded zlib/1.2.11 from 'conancenter' - Downloaded Packages bzip2/1.0.8:5be2b7a2110ec8acdbf9a1cea9de5d60747edb34 - Download expat/2.2.9:6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7 - Download openssl/1.1 that an existing build script is simultaneously building binaries for different configurations, like de- bug/release, or different architectures (32/64bits), or library types (shared/static). If such a build0 码力 | 823 页 | 7.06 MB | 1 年前3Conan 1.41 Documentation
def build(self): # Responsible for␣ ˓→invoking the build system cmake = CMake(self) # Helper classes␣ ˓→are available for several build systems ... self.run("bin/unittests") # Run unit tests␣ ˓→compiled Downloaded zlib/1.2.11 from 'conancenter' - Downloaded Packages bzip2/1.0.8:5be2b7a2110ec8acdbf9a1cea9de5d60747edb34 - Download expat/2.2.9:6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7 - Download openssl/1.1 that an existing build script is simultaneously building binaries for different configurations, like de- bug/release, or different architectures (32/64bits), or library types (shared/static). If such a build0 码力 | 835 页 | 7.10 MB | 1 年前3
共 217 条
- 1
- 2
- 3
- 4
- 5
- 6
- 22