Lightning Talk: When C++ Singletons Fail... Richard Shepherd - C++ on Sea 2023

Поділитися
Вставка
  • Опубліковано 12 вер 2024
  • cpponsea.uk/
    ---
    Lightning Talk: When C++ Singletons Fail... Richard Shepherd - C++ on Sea 2023
    Singletons can be created uniquely, in a thread safe manner, but if there is a problem during construction, are you stuck with it?
    ---
    Slides: github.com/phi...
    Sponsored By think-cell: www.think-cell...
    ---
    Richard Shepherd
    I'm a developer and team lead for Esri's Cardiff R&D center.
    ---
    C++ on Sea is an annual C++ and coding conference, in Folkestone, in the UK.
    - Annual C++ on Sea, C++ conference: cpponsea.uk/
    - 2023 Program: cpponsea.uk/20...
    - Twitter: / cpponsea
    ---
    UA-cam Videos Filmed, Edited & Optimised by Digital Medium: events.digital...
    #cpp​ #cpponsea​ #cppprogramming

КОМЕНТАРІ • 5

  • @jamessutton9323
    @jamessutton9323 10 місяців тому +2

    Singletons should be used in only very rare special cases. They are effectively global variables with all the problems that they bring. I worked for a company which used 100s of singletons and it was a complete mess! It was very difficult to maintain the code as you didn't know where the hidden singleton state might be accessed or even modified in any method you called. Also when it was decided that it was required to run multiple instances of the library a special wrapper had to be designed to handle the singletons, creating a single instance for each instantiation of the library. Effectively it was a short-sighted lazy policy to avoid passing an object as argument into each call that used it.

  • @RyanLynch1
    @RyanLynch1 10 місяців тому

    very good side benefit of using a pointer to hint the user to check the validity

  • @default-writer
    @default-writer 10 місяців тому +1

    This code was a garbage and keeped a garbage. Nothing really happens anyway. You need to remove singletons from C++ cause you do not need it in C++. Argumen is that this is an example of breaking SOLID and KISS, two responsibilities of class to exists makes this class hard to test and support, no need such complications in just once class.

  • @kayakMike1000
    @kayakMike1000 10 місяців тому

    C++ is an awful programming language. Just stop C++.