Back to Basics: Designing Classes (part 1 of 2) - Klaus Iglberger - CppCon 2021

  Рет қаралды 81,709

CppCon

CppCon

Күн бұрын

cppcon.org/
github.com/CppCon/CppCon2021
---
Designing good, maintainable classes is a challenge. Sometimes it even feels like there is a decision to make in every single line of code. This talk will help you master this challenge. It will explain …
* … why small classes are beautiful;
* … why it is so important to encapsulate variation points;
* … why inheritance is rarely the answer for customization;
* … how to write good and maintainable constructors;
* … how to make sure class invariants are maintained;
* … how to handle member data;
* … how to write good member functions;
* … how to write good supporting functions;
* … why your private members are not private at all.
---
Klaus Iglberger
Klaus Iglberger is a freelancing C++ trainer and consultant. He has finished his PhD in computer science in 2010 and since then is focused on large-scale C++ software design. He shares his experience in popular advanced C++ courses around the world (mainly in Germany, but also the EU and US). Additionally, he is the initiator and lead designer of the Blaze C++ math library (bitbucket.org/blaze-lib/blaze...) and one of the organizers of the Munich C++ user group (www.meetup.com/MUCplusplus/).
---
Videos Recorded & Edited by Digital Medium: online.digital-medium.co.uk
*--*

Пікірлер: 70
@omid_tau
@omid_tau 2 жыл бұрын
one of the worlds greatest speakers on c++. No idea we he hasn't published a book, or even recorded his workshops.
@lehaipham4622
@lehaipham4622 2 жыл бұрын
This is just pure gold! I wish I could find more similar quality talks. Not sure if any other good ones, there are so many talks uploaded recently, which overwhelm my digestion.
@MyMjrox
@MyMjrox 2 жыл бұрын
Great presentation. To the point with clear examples . Klaus doesn't disappoint.
@CppCon
@CppCon 2 жыл бұрын
Much appreciated!
@pabstkkx
@pabstkkx 2 жыл бұрын
He never does :)
@8Trails50
@8Trails50 2 жыл бұрын
One of the best talks I’ve ever seen.
@simonfarre4907
@simonfarre4907 2 жыл бұрын
Klaus talks are always very qualitatively dense and great. Back to basics or not, always useful.
@CppCon
@CppCon 2 жыл бұрын
Glad you like them!
@iamjadedhobo
@iamjadedhobo 2 жыл бұрын
Everyone needs a refresher now and then :) This one held me captivated for the entire duration.
@mehtubbhai9709
@mehtubbhai9709 2 жыл бұрын
Another great talk from Klaus. Always look forward to his Back to Basics talks
@CppCon
@CppCon 2 жыл бұрын
Glad you enjoyed it!
@learntolearn3063
@learntolearn3063 2 жыл бұрын
Excellent talk Klaus. Definitely its one of the best back to basic on design class. Am a big fun of you.
@CostaKazistov
@CostaKazistov 2 жыл бұрын
Really enjoying this series. Klaus Iglberger is an excellent presenter. Looking forward to more Back to Basics videos.
@CppCon
@CppCon 2 жыл бұрын
Glad you like them!
@thestarinthesky_
@thestarinthesky_ Ай бұрын
Awesome! Thanks for sharing!
@jmbrjmbr2397
@jmbrjmbr2397 2 жыл бұрын
Thank you soo much for these valuable lessons! Code examples made it very clear to me.
@CppCon
@CppCon 2 жыл бұрын
Glad it was helpful!
@sotirissalloumis6129
@sotirissalloumis6129 2 жыл бұрын
Excellent presentation, congratulations to the presenter and a big thanks to CppCon for sharing..
@CppCon
@CppCon 2 жыл бұрын
Thank you too!
@vadumsenkiv8773
@vadumsenkiv8773 Жыл бұрын
Thank you so much for such great presentation 🔥
@oleholgerson3416
@oleholgerson3416 2 жыл бұрын
Thank you very much Klaus, excellent talk!
@CppCon
@CppCon 2 жыл бұрын
Many thanks!
@yangwei6761
@yangwei6761 2 жыл бұрын
Thanks for speaking from experience.
@antonfernando8409
@antonfernando8409 2 жыл бұрын
Excellent, you explain things very well, practical and to the point.
@CppCon
@CppCon 2 жыл бұрын
Glad you think so!
@greob
@greob 2 жыл бұрын
Nice presentation, easy to follow and understand. Klaus is a great teacher.
@CppCon
@CppCon 2 жыл бұрын
Many thanks!
@fatpo2396
@fatpo2396 11 ай бұрын
great presentation and easy to understand
@vishnuuppada2181
@vishnuuppada2181 2 жыл бұрын
Very Informative talk on design decisions !!!
@CppCon
@CppCon 2 жыл бұрын
Glad you liked it
@maneshipocrates2264
@maneshipocrates2264 Жыл бұрын
Good talk. Enjoyed his training in my uni.
@CppCon
@CppCon Жыл бұрын
Great to hear!
@jphvnet
@jphvnet Жыл бұрын
Really good talk
@LiveseyMD
@LiveseyMD 2 жыл бұрын
Thanks for a really useful talk!
@CppCon
@CppCon 2 жыл бұрын
Glad it was helpful!
@thodin87
@thodin87 Жыл бұрын
29:10: I really like the idea of providing the DrawStrategy by means of a template argument to the class. Unfortunately, the slide does not show how one would instantiate such a class. I managed to do this via a functor that I give as the template argument. However, is it also possible via a Lambda or via std::function? Would be very grateful if someone could explain how to do that.
@paulina5247
@paulina5247 2 жыл бұрын
Great lecture!
@CppCon
@CppCon 2 жыл бұрын
Thank you!
@jimfcarroll
@jimfcarroll 2 жыл бұрын
"#define private public", at least at one point, didn't work with Microsoft compilers because they included the access region in the name mangling.
@Solarbonite
@Solarbonite 2 жыл бұрын
Thank you so much for this talk! I need to get a copy of the gang of four book and test out the new features in the standard. I think that learning this is super valuable.
@CppCon
@CppCon 2 жыл бұрын
Glad it was helpful!
@peterevans6752
@peterevans6752 2 жыл бұрын
Great presentation.
@CppCon
@CppCon 2 жыл бұрын
Thanks for watching
@peregrin71
@peregrin71 Жыл бұрын
About testing private members (of a class type). I would phrase it slightly different. Do NOT test them as part of the owning class. If it is a private member of a specific other class type then test the member class in isolation first. Also allow for the member to be injectable (inject interface or as template parameter) so you can test the using class using a "mocked instance" as member.
@PedrosoJr
@PedrosoJr 2 жыл бұрын
Very nice presentation!
@CppCon
@CppCon 2 жыл бұрын
Thank you very much!
@dadisuperman3472
@dadisuperman3472 2 жыл бұрын
Designing classes is a constant search for orthogonalities. Exple: Circle->(implements)->the shape interface. Circle::draw -> calls RenderEngine::draw. Circle::draw generates the vertices of a circle, RenderEngine::draw uses whatever drawing engine (opengl, vulkan, Dx..etc) to lay these vertices on a color buffer. Instantiating a Circle by giving it a derived class of "DrawXXXXstrategy" means the user have to know which concrete class he has to use to render his circle. However this information is only relevant to the render engine, it is the one and only object which should know about the underlying platform. As an implementer of circle::draw method, i have only to say: void circle::draw(radius, resolution) { vector circumference; for(int i=0; i
@8Trails50
@8Trails50 2 жыл бұрын
great advice. any books / resources you recommend?
@sirhenrystalwart8303
@sirhenrystalwart8303 2 жыл бұрын
I would prefer Length to Size for the second array template parameter. Size is too easily confused with the size in memory, and in some ways (e.g., sizeof) could be more confusing than just N.
@masheroz
@masheroz 2 жыл бұрын
You can apply the law of least suprise here too; the stl containers use size, so use that one as well.
@think2086
@think2086 Жыл бұрын
Why are the Germans such good C++ teachers?
@bongo990
@bongo990 9 ай бұрын
Maybe because there are a lot of users of C++ in Germany and people had to get good in it because they were using it so much. I mean considering that Germany produces a lot of mechanization and industrial equipment..
@nandanvasudevan
@nandanvasudevan 2 жыл бұрын
13:29 Can anyone tell me what font is that (for the class definition) ? Its gorgeous!
@nandanvasudevan
@nandanvasudevan 2 жыл бұрын
It's PT Mono.
@eyesopen6110
@eyesopen6110 6 ай бұрын
Doesn't the std::function version of the Strategy pattern leave it open to any and all callable with the function signature?... No type checking at all?....
@georgesimeonidis8695
@georgesimeonidis8695 2 жыл бұрын
At 43:34 he says that by making the test class a friend you couple it into the production code. Can someone elaborate?
@verdantblast
@verdantblast 2 жыл бұрын
You mean 42:35? My understanding is that if you make the test class as a friend, then this line of declaration will pollute your actual code of specific functions. Imagine that the production environment code does not have any test class, then the line of code will become dead and will never be used.
@iliasalaur
@iliasalaur 11 ай бұрын
41:13 #define class struct is of course the best option here, as showed in the first answer😂
@pajeetsingh
@pajeetsingh Ай бұрын
What operating system does Klaus use?
@schmardin0815
@schmardin0815 Жыл бұрын
Slide 79: You cannot implement copy ctor or assignment for that class. A type that has a move-only member like std::unique_ptr is automatically move-only as well. There is no Rule of 5 in this case.
@dennydaydreamer
@dennydaydreamer Жыл бұрын
Isn't it only the compiler-generated copy constructor is inhibited? I tried to create the same Widget class in MSVC and there was no problem to create a user-defined copy constructor. You just need to do something different than move for the unique_pointer member, perhaps initialise it with a factory/clone method?
@davithov
@davithov Жыл бұрын
I didn't understand a few things. It would be nice to have more examples. For example, how 'destroy' function should be moved away to make it testable. Also when explaining "Template Method" 's purpose, you said that it solves certain type of problem, but I didn't understand where the problem is in that case.
@srenh-p3798
@srenh-p3798 2 жыл бұрын
That feel when having used #define private public a bunch of time in unit tests 😅. It is a hack indeed, and it is probably truly ghastly, but I don't think he really justifies that. Why is it actually so bad?
@codebus
@codebus Жыл бұрын
Your rapper name is Santa Klaus
@cmdrwhiskeygalore3044
@cmdrwhiskeygalore3044 11 ай бұрын
Less data at the expense of more code is the only way. In real time you have to throw away good design in favour of less calls and the only way you can do that is make more functions, more code, that only need to be called once. The call itself carries values inherently and virtualisation provides that far better than delegation. When you connect to a real-time server you have to throw relationships out of the window. They are too inefficient. This back and forth as you traverse the data relationships is all wrong. Send one query. Get back a block that contains enough data that will stop you from having to retrieve relationships by sending more queries. Polymorphism carries implied intent. Delegation does not.
@milad6914
@milad6914 Жыл бұрын
not fun indeed
@norbertnemesh
@norbertnemesh 8 ай бұрын
This performance is dramatic that it gives me cringe overflow with undefined behaviour
@0XAN
@0XAN 2 ай бұрын
apply those principles descibed on the video is the best way to achieve slow code and the slow code for me is pure evil
UFC 302 : Махачев VS Порье
02:54
Setanta Sports UFC
Рет қаралды 1,3 МЛН
Can you beat this impossible game?
00:13
LOL
Рет қаралды 53 МЛН
8 Design Patterns | Prime Reacts
22:10
ThePrimeTime
Рет қаралды 381 М.
Why Isn't Functional Programming the Norm? - Richard Feldman
46:09
Domain-Driven Refactoring - Jimmy Bogard - NDC London 2022
1:00:03
NDC Conferences
Рет қаралды 43 М.
Очень странные дела PS 4 Pro
1:00
ТЕХНОБЛОГ ГУБАРЕВ СЕРГЕЙ
Рет қаралды 375 М.
С Какой Высоты Разобьётся NOKIA3310 ?!😳
0:43
Выложил СВОЙ АЙФОН НА АВИТО #shorts
0:42
Дмитрий Левандовский
Рет қаралды 1,7 МЛН
How charged your battery?
0:14
V.A. show / Магика
Рет қаралды 3,4 МЛН
What model of phone do you have?
0:16
Hassyl Joon
Рет қаралды 74 М.