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

แชร์
ฝัง

ความคิดเห็น • 70

  • @lehaipham4622
    @lehaipham4622 2 ปีที่แล้ว +37

    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 ปีที่แล้ว +28

    Great presentation. To the point with clear examples . Klaus doesn't disappoint.

    • @CppCon
      @CppCon  2 ปีที่แล้ว +1

      Much appreciated!

    • @pabstkkx
      @pabstkkx 2 ปีที่แล้ว

      He never does :)

  • @omid_tau
    @omid_tau 2 ปีที่แล้ว +6

    one of the worlds greatest speakers on c++. No idea we he hasn't published a book, or even recorded his workshops.

  • @jimfcarroll
    @jimfcarroll 2 ปีที่แล้ว +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.

  • @mehtubbhai9709
    @mehtubbhai9709 2 ปีที่แล้ว +11

    Another great talk from Klaus. Always look forward to his Back to Basics talks

    • @CppCon
      @CppCon  2 ปีที่แล้ว +1

      Glad you enjoyed it!

  • @sirhenrystalwart8303
    @sirhenrystalwart8303 2 ปีที่แล้ว +5

    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.

  • @thodin87
    @thodin87 2 ปีที่แล้ว +2

    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.

  • @srenh-p3798
    @srenh-p3798 2 ปีที่แล้ว +1

    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?

  • @8Trails50
    @8Trails50 2 ปีที่แล้ว +4

    One of the best talks I’ve ever seen.

  • @eyesopen6110
    @eyesopen6110 10 หลายเดือนก่อน

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

  • @cmdrwhiskeygalore3044
    @cmdrwhiskeygalore3044 ปีที่แล้ว

    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.

  • @think2086
    @think2086 ปีที่แล้ว +1

    Why are the Germans such good C++ teachers?

    • @bongo990
      @bongo990 ปีที่แล้ว

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

  • @simonfarre4907
    @simonfarre4907 2 ปีที่แล้ว +2

    Klaus talks are always very qualitatively dense and great. Back to basics or not, always useful.

    • @CppCon
      @CppCon  2 ปีที่แล้ว

      Glad you like them!

  • @dadisuperman3472
    @dadisuperman3472 2 ปีที่แล้ว +4

    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?

  • @learntolearn3063
    @learntolearn3063 2 ปีที่แล้ว +1

    Excellent talk Klaus. Definitely its one of the best back to basic on design class. Am a big fun of you.

  • @jmbrjmbr2397
    @jmbrjmbr2397 2 ปีที่แล้ว +2

    Thank you soo much for these valuable lessons! Code examples made it very clear to me.

    • @CppCon
      @CppCon  2 ปีที่แล้ว

      Glad it was helpful!

  • @pajeetsingh
    @pajeetsingh 5 หลายเดือนก่อน

    What operating system does Klaus use?

  • @vishnuuppada2181
    @vishnuuppada2181 2 ปีที่แล้ว +2

    Very Informative talk on design decisions !!!

    • @CppCon
      @CppCon  2 ปีที่แล้ว +1

      Glad you liked it

  • @iamjadedhobo
    @iamjadedhobo 2 ปีที่แล้ว +1

    Everyone needs a refresher now and then :) This one held me captivated for the entire duration.

  • @vadumsenkiv8773
    @vadumsenkiv8773 2 ปีที่แล้ว +1

    Thank you so much for such great presentation 🔥

  • @CostaKazistov
    @CostaKazistov 2 ปีที่แล้ว +1

    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!

  • @sotirissalloumis6129
    @sotirissalloumis6129 2 ปีที่แล้ว +1

    Excellent presentation, congratulations to the presenter and a big thanks to CppCon for sharing..

    • @CppCon
      @CppCon  2 ปีที่แล้ว

      Thank you too!

  • @davithov
    @davithov 2 ปีที่แล้ว

    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.

  • @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.

  • @antonfernando8409
    @antonfernando8409 2 ปีที่แล้ว +1

    Excellent, you explain things very well, practical and to the point.

    • @CppCon
      @CppCon  2 ปีที่แล้ว +1

      Glad you think so!

  • @yangwei6761
    @yangwei6761 2 ปีที่แล้ว +5

    Thanks for speaking from experience.

  • @jphvnet
    @jphvnet 2 ปีที่แล้ว +1

    Really good talk

  • @maneshipocrates2264
    @maneshipocrates2264 2 ปีที่แล้ว +1

    Good talk. Enjoyed his training in my uni.

    • @CppCon
      @CppCon  2 ปีที่แล้ว

      Great to hear!

  • @iliasalaur
    @iliasalaur ปีที่แล้ว

    41:13 #define class struct is of course the best option here, as showed in the first answer😂

  • @thestarinthesky_
    @thestarinthesky_ 5 หลายเดือนก่อน

    Awesome! Thanks for sharing!

  • @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 ปีที่แล้ว +1

      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?

  • @LiveseyMD
    @LiveseyMD 2 ปีที่แล้ว +1

    Thanks for a really useful talk!

    • @CppCon
      @CppCon  2 ปีที่แล้ว

      Glad it was helpful!

  • @fatpo2396
    @fatpo2396 ปีที่แล้ว

    great presentation and easy to understand

  • @codebus
    @codebus ปีที่แล้ว

    Your rapper name is Santa Klaus

  • @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 ปีที่แล้ว +1

      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.

  • @nandanvasudevan
    @nandanvasudevan 2 ปีที่แล้ว

    13:29 Can anyone tell me what font is that (for the class definition) ? Its gorgeous!

  • @milad6914
    @milad6914 ปีที่แล้ว

    not fun indeed

  • @oleholgerson3416
    @oleholgerson3416 2 ปีที่แล้ว

    Thank you very much Klaus, excellent talk!

    • @CppCon
      @CppCon  2 ปีที่แล้ว

      Many thanks!

  • @PedrosoJr
    @PedrosoJr 2 ปีที่แล้ว

    Very nice presentation!

    • @CppCon
      @CppCon  2 ปีที่แล้ว

      Thank you very much!

  • @peterevans6752
    @peterevans6752 2 ปีที่แล้ว

    Great presentation.

    • @CppCon
      @CppCon  2 ปีที่แล้ว

      Thanks for watching

  • @paulina5247
    @paulina5247 2 ปีที่แล้ว

    Great lecture!

    • @CppCon
      @CppCon  2 ปีที่แล้ว

      Thank you!

  • @Solarbonite
    @Solarbonite 2 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      Glad it was helpful!

  • @norbertnemesh
    @norbertnemesh ปีที่แล้ว

    This performance is dramatic that it gives me cringe overflow with undefined behaviour

  • @0XAN
    @0XAN 5 หลายเดือนก่อน

    apply those principles descibed on the video is the best way to achieve slow code and the slow code for me is pure evil

  • @greob
    @greob 2 ปีที่แล้ว

    Nice presentation, easy to follow and understand. Klaus is a great teacher.

    • @CppCon
      @CppCon  2 ปีที่แล้ว

      Many thanks!