No video

The Singleton Pattern - Anti-Pattern or Solution? - Klaus Iglberger - C++ on Sea 2022

  Рет қаралды 3,659

cpponsea

cpponsea

Күн бұрын

C++ on Sea Website: cpponsea.uk/
C++ on Sea Twitter: / cpponsea
---
The Singleton Pattern - Anti-Pattern or Solution? - Klaus Iglberger - C++ on Sea 2022
Slides: github.com/phi...
Singleton is indeed a rather infamous pattern: There are many voices out there that describe Singleton as a general problem in code, as an anti-pattern, as dangerous, or even as evil. Still, despite the bad reputation and the many negative aspects, if used judiciously and if implemented properly,
Singleton has proven to be a useful solution for representing the few global aspects in your code.
This talk tries to give a balanced overview of the Singleton pattern. I will show the cons as well as the pros and will demonstrate how to properly deal with Singletons to overcome the major disadvantages. In particular, I will show how to implement Singletons such that dependencies to implementation details are avoided, code can be easily changed and full testability is given.
---
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/...) and a (co-)organizer of the Munich C++ user group (www.meetup.com....
---
C++ on Sea is an annual C++ and coding conference, in Folkestone, in the UK. The 2022 conference was conducted as a two part, physical and online C++ event.
- Annual C++ on Sea, C++ conference: cpponsea.uk/
- 2022 Program: cpponsea.uk/20...
---
Produced and Edited by Digital Medium Ltd: events.digital...
Enquiries: events@digital-medium.co.uk
#Programming​ #Cpp​ #CppOnSea​

Пікірлер: 4
@user-kf8yp9vl9p
@user-kf8yp9vl9p Жыл бұрын
Definitely something to use carefully, but sometimes the best solution. The example Klaus gives is what I commonly refer to as a "Supper Simple Singleton" -- in this case it simply provides a pointer to the implementing object. Another Supper Simple Singleton that I have used many times is a registry for a service. Objects that want to use the service register and then the service calls them. Note that this is for embedded systems that never stop or change registration after initialization. Thanks!
@Roibarkan
@Roibarkan Жыл бұрын
Very thought provoking talk, Thanks Klaus. Another c++ use case which might relate to the topic is the “predicate” member of std::map or the “hasher” of std::unordered_map. There too, the STL uses the ‘strategy’ pattern, yet specific implementations/instantiations might require (implementation detail?) only a single object used. To some extent p1169 adds the notion of such singletons to c++23 (classes with static operator(), that might themselves have static variables)
@Roibarkan
@Roibarkan Жыл бұрын
12:12 (slide 22) - as an “implementation pattern” I think one of the merits of hiding globals as static variables in functions is that they handle initialization order fairly well
@sanderjobing
@sanderjobing 2 жыл бұрын
Anti-pattern: Can introduce global state and does not comply to the Liskov substitution principle. So difficult testable.
C++ on Sea Lightning Talks: Omnibus Session 1 - C++ on Sea 2023
57:36
КТО ЛЮБИТ ГРИБЫ?? #shorts
00:24
Паша Осадчий
Рет қаралды 1,2 МЛН
Fortunately, Ultraman protects me  #shorts #ultraman #ultramantiga #liveaction
00:10
Son ❤️ #shorts by Leisi Show
00:41
Leisi Show
Рет қаралды 11 МЛН
The Pointer to Implementation (pImpl) idiom in C++
6:54
platis.solutions
Рет қаралды 14 М.
How This New Battery is Changing the Game
12:07
Undecided with Matt Ferrell
Рет қаралды 209 М.
Foucault - Patron Saint of Child Indoctrination | Logan Lancing
11:58
Jordan B Peterson
Рет қаралды 95 М.
КТО ЛЮБИТ ГРИБЫ?? #shorts
00:24
Паша Осадчий
Рет қаралды 1,2 МЛН