1. 7

    Season 3 of Dark comes out on Saturday (in the US at least), so I’ll be parked in front of the TV for several hours.

    I’ll probably get a round of disc golf in on Sunday. Do we have any European disc golfers here? If so, what’s it like in your area?

    1. 2

      Some cities have some hidden in parks. I have seen some at least in Brussels, Louvain-la-Neuve and Amsterdam. Done it a few time for fun but it is pretty rare hobby around here.

      1. 1

        Are you me (from another dimension/time :))? This is exactly what I’m doing this weekend: watching Dark and playing disc golf!

        Do we have any European disc golfers here?

        Yes, I’m a disc golfer from Europe. What exactly do you want to know, how is it now due to COVID or more in general?

        1. 1

          I was just curious what the scene is like in other countries e.g. how popular is it, are there many courses near you, etc.

          I’ve seen that Sweden and Finland have a huge number of courses, but I don’t know much about the rest of Europe.

          1. 1

            how popular is it, are there many courses near you, etc.

            I can tell you only for Croatia.

            Not very popular here, we have around 40 players on our tournaments (more active players than that, but noting to write home about).
            I have a course about 40 minute drive away from me, and then the next one is 3 hours away :D

            1. 1

              That’s interesting. I live in a small college town and even here there are 5 courses near me, and a handful more in Indianapolis (~1hr away).

              1. 1

                there are 5 courses near me

                We have 5 courses in the whole country!

                Four of which are relatively close to each other (maybe half an hour between each; all ~3 hours away from me), and one is near me. There are some talks about some new courses, but nothing happened yet.

        2. 1

          Totally forgot about the new Dark season, thanks for the reminder!

          1. 1

            I am doing the same on Saturday, rewatched dark a few weeks ago to catch up.

            A second watch of the show was surprisingly illuminating.

            1. 1

              I did my rewatch last weekend. A second watch is definitely interesting!

          1. -2

            Tag suggestion: “show” instead of “programming”. Also seems like a low-effort post.

            1. 19

              Added show, but the site won’t let me remove programming.

              I certainly spent many hours on this post, so not sure why you think it’s low-effort? :)

              1. 5

                We have annual battlestations threads. You just missed the last one. You can, of course, still comment there.

                And I suggest your tags match them: practices

                1. 10

                  Thanks! I’ll keep an eye on the 2021 version then, I guess.

                  Added a comment to the 2020 thread, too, and updated the tags. Thanks for the hint

                2. 1

                  Everyone has a desk and can write about it, not everyone has your knowledge of Objective-C or can write about that.

                  1. 18

                    But I found it a thoughtful post that not only listed hardware, but also explained why it’s beneficial. It’s a good read.

                    1. 8

                      true, everyone has a desk but the post also has

                      Window manager: i3 It won’t be a surprise that I am using the i3 tiling window manager, which I created in 2009 and still maintain.

                      And the projects written in Go, including the router7 or debian code search.

                      I would say that the title does a tiny bit disservice to the content in the post itself.

                      1. 2

                        Being the writer of i3 makes the point even stronger. Imagine the interesting posts he could write about i3 and window managers. Instead we get a post about what he has on his desk.

                        How does writing i3 make his desk any more interesting? He didn’t write i3 because his desk was set up a particular way.

                        1. 1

                          But even then the “content” is just a list of products or programs the author has bought, used or developed. There’s nothing to really be learned or gained from such a list.

                          1. 8

                            i learned a few things from the post though.

                            1. Multiproject management through emacs- org mode.
                            2. serialize thoughts by writing them down on a physical notebook
                            3. authors reasons for choosing
                            • Go
                            • Single monitor
                            1. 3

                              You needed the developer of i3 to tell you that you can write things down in a notebook?

                              1. 7

                                i mean, i like learning about people’s workflow. Like i learned about bullet journal from a lobsters thread in 2016 and it was a game changer for me.

                              2. 2

                                Let’s be real, you’ve heard all this stuff before and know it well: This isn’t the first time you’ve seen “serialise thoughts by writing them down” or “Go is great because of x”.

                                1. 12

                                  If you recognized this as a “one of many” posts then feel free to skip it, but it is certainly not low effort and apparently did interest quite a few of us.

                    1. 3

                      I recently learned that solving a problem requires bread-first effort, asking how can i get a working solution as soon as possible. Once that is ready, find the bottleneck, fix that in a bread first way.

                      Keep a notebook where you start with what you want to do and what are the necessary tasks, it’s ok to deviate but always keep the bigger picture in mind.

                      1. 4

                        Once that is ready, find the bottleneck, fix that in a bread first way.

                        I definitely approve of eating bread before doing work. It’s hard to concentrate on an empty stomach.

                        (You meant breadth-first. Sorry for making your response the butt of the bread joke.)

                        1. 5

                          you found my typo, dough! You can Loaf at me all you want.

                      1. 15

                        Breadth-first, not depth. Defer relentlessly. Check with your primary goal regularly. Time-boxing.

                        The trick with making meaningful progress and not spinning out on these tangents is pausing to recognize them as tangents. Only execute on a sub-task if it is necessary to complete your immediate goal. If a sub-tasks can be deferred, do that; You can evaluate if they are still useful later. Capturing them to get it out of your head should alleviate some of the pull that they have on you – they won’t be forgotten, but don’t need to be done now.

                        And always be asking the question “Is this helping me solve my immediate problem?”. Why did you want the interactive debugger? Probably for more context. For debugging specifically, always be asking is there a dumber/simpler way to find concrete information? Just sitting and thinking through the specific context that you think you need may have allowed you to continue with print debugging might have short-circuited the tangent.

                        The other tactic that can help is, when you start a sub-goal, estimate how much time it is worth to you, and set a timer. Had you valued the interactive debugger at 20m, and then the timer went off and you realized that you were about to re-install your interpreter. That is a good moment to re-evaluate. And having the concrete time box prevents you from losing an entire afternoon to a chain of those.

                        As a reminder, maybe put a sticky note in front of you with your current goal. And keep checking in that you are still really working towards it.

                        As for tooling, omnifocus and dynalist.io both have quick capture features for things you can defer until later. And dynalist.io and workflowy literally let you nest these tangents, which can be a visual signal when you’ve gone too far. But I think the crux of your question is more about focus and process and less about the tools.

                        1. 1

                          Breadth-first

                          I’ve learned this recently and changing from depth first has been tough but very helpful. How did you land upon this concept? and how do you practice it?

                          1. 1

                            I’ve spent a lot of time in my own rabbit holes. Learning to slow down and take a step back is mindfulness and practice. Something I still strive for, and sometimes fail at.

                            Practically speaking ideas like MVPs and Tracer Bullets are have pushed me in this direction – See Pragmatic Programmer. Getting something thing in front of people as a way to understand what is important, and to quickly change things that aren’t working without spending a ton of time on them has worked well for me. Doing things this way you go wide, shallow, and simple for each feature. Inevitably when you’re writing a feature a hundred ideas and edge cases and thoughts come up, and you just have to throw them at the end of the list – If the feature survives or is important you can go deeper on it. That has meant a lot of practice adding to the end of my todo list rather than the middle.

                            As for “Breadth-first”, the original question’s use of recursion just made me think of depth-first graph traversal. So breadth-first being the opposite sprung to mind, though I was basically describing it as a FIFO queue, not so different I suppose.

                            1. 1

                              I love the idea of this, how a lot of people are think of and realizing the same thing at the same time as a product of the culture they love in.

                              (I ordered para prog v2 two weeks ago)

                              Thanks for your answer!

                        1. 13

                          Off the top of my head:

                          • Statistical control charts (a.k.a. process behaviour charts). I have a tiny JavaScript file that takes a numeric series and plots it onto an XmR (a.k.a. individuals) chart. I use it for double-checking everything these days.

                          • Perl 5. As long as I’m dealing with plain text, there’s no faster way to go from hypothesis to theory on any server.

                          • Good headphones. What makes an open-plan office survivable for me.

                          • Reading a lot about how they do things in engineering/scientific fields different from mine. There’s a lot of untapped knowledge as soon as you start thinking across field boundaries.

                          1. 4

                            Statistical control charts (a.k.a. process behaviour charts). I have a tiny JavaScript file that takes a numeric series and plots it onto an XmR (a.k.a. individuals) chart. I use it for double-checking everything these days.

                            Based on your other comment, you seem to be well versed with statistical process control. What would be a good resource for learning?

                            1. 5

                              Specifically in terms of control charts, there is a wealth of information and corrections to common misconceptions written by Wheeler made freely available at the Quailty Digest website (the only catch is you have to sign up for an account). Without this treasure trove, I wouldn’t have known nearly enough to apply them efficiently now. https://www.qualitydigest.com/read/content_by_author/12852

                              For more general context, I’ll repeat my suggestion to read the books by Deming, and Shewhart. No particular book recommended: they’re all good and cover generally the same things except with slightly different perspectives (which makes it useful to read all of them, but not necessary to get an idea of the concepts involved.)

                            2. 1

                              Reading a lot about how they do things in engineering/scientific fields different from mine. There’s a lot of untapped knowledge as soon as you start thinking across field boundaries.

                              any books/blogs you’d recommend?

                              1. 4

                                Too numerous to be specific, but things I’ve had use for include:

                                • queuing theory from telecom (but careful! subscriber arrival rates and service times may be poisson/exponential, but open systems may be better modeled as lognormal – or better yet, with a histogram of actual observations.)

                                • sequence homology from bioinformatics

                                • human interface design from military systems (DoD design criteria are an example of a book here)

                                • system failure analysis from avionics (not avionics-based, but Leveson writes well about this)

                                • (obviously) statistical process control from manufacturing (all three of Deming, Shewhart, and Wheeler)

                                • digital signal processing from electronic music

                                • conducting effective trials from medicine

                                • conciseness from fiction writing (Palahniuk, Hemingway, and King are inspirational)

                                • system analysis from environmental science (donatella meadows is one place to start)

                                1. 1

                                  Oh we have same interests, thanks for the pointers i’ll follow up on these!

                                  • system analysis from environmental science (donatella meadows is one place to start)

                                  Read this last year, now finding papers by Russel Ackoff. this is a good place to start

                            1. 3

                              Apart from $work, i am going to continue reading Crafting Interpreters already half way through and am really enjoying it.

                              1. 1

                                It’s an excellent book. I’ve already cribbed his ideas with using stack-allocated values vs. having all values be allocated on the heap. Are you following it exactly and making a version of Lox?

                                1. 2

                                  I am not implementing the ast based interpreter since I’ve built a quite a few of those already. Learning the byte code vm instead.

                              1. 1

                                They included The Passionate Programmer but NOT The Pragmatic Programmer

                                raised eyebrow.

                                1. 1

                                  At the time of my talk “The Pragmatic Programmer” wasn’t as relevant as before, as many of the key insights there had become common practices today. Still, there’s no argument that it’s a very important book in the history of programming. Haven’t seen the updated edition, though.

                                  1. 2

                                    That’s a perfectly reasonable take.

                                    However I like to say that common practice isn’t always as common as you’d think :)

                                    It’s very easy for people to do Just Enough to fly under the radar when in fact their actual day to day craft embodies practices that would make most Crustaceans cringe.

                                    I speak from experience on this matter, since I resembled that remark for many years, and still do in some areas :)

                                    1. 3

                                      I speak from experience on this matter, since I resembled that remark for many years, and still do in some areas :)

                                      I appreciate the self deprecation.

                                      More seriously, it’s hard to do everything right and sometimes on teams it’s hard to even do the things you like doing.

                                      1. 2

                                        More seriously, it’s hard to do everything right and sometimes on teams it’s hard to even do the things you like doing.

                                        Totally. The trick is figuring out which things are “more right” in a way that represents actual functional difficulties as opposed to just somebody’s version of what’s elegant or idiomatic.

                                        For instance, I’d argue that using some form of version control isn’t just best practice, it’s a strong way to keep you from shooting yourself in the foot :)

                                    2. 2

                                      “The Pragmatic Programmer” was updated in January 2020. I haven’t read the 20th anniversary edition yet though.

                                  1. -1

                                    The best SRE recommendation around Memcached is not to use it at all:

                                    • it’s pretty much abandonware at this point
                                    • there is no built-in clustering or any of the HA features that you need for reliability

                                    Don’t use memcached, use redis instead.

                                    (I do SRE and systems architecture)

                                    1. 30

                                      … there was literally a release yesterday, and the project is currently sponsored by a little company called …[checks notes]…. Netflix.

                                      Does it do everything Redis does? No. Sometimes having simpler services is a good thing.

                                      1. 11

                                        SRE here. Memcached is great. Redis is great too.

                                        HA has a price (Leader election, tested failover, etc). It’s an antipattern to use HA for your cache.

                                        1. 9

                                          Memcached is definitely not abandonware. It’s a mature project with a narrow scope. It excels at what it does. It’s just not as feature rich as something like Redis. The HA story is usually provided by smart proxies (twemcache and others).

                                          1. 8

                                            It’s designed to be a cache, it doesn’t need an HA story. You run many many nodes of it and rely on consistent hashing to scale the cluster. For this, it’s unbelievably good and just works.

                                            1. 3

                                              seems like hazelcast is the successor of memcached https://hazelcast.com/use-cases/memcached-upgrade/

                                              1. 3

                                                I would put it with a little bit more nuance: if you have already Redis in production (which is quite common), there is little reason to add memcached too and add complexity/new software you may have not as much experience with.

                                                1. 1

                                                  this comment is ridiculous

                                                  1. 1

                                                    it’s pretty much abandonware at this point

                                                    i was under the impression that facebook uses it extensively, i guess redis it is.

                                                    1. 10

                                                      Many large tech companies, including Facebook, use Memcached. Some even use both Memcached and Redis: Memcached as a cache, and Redis for its complex data structures and persistence.

                                                      Memcached is faster than Redis on a per-node basis, because Redis is single-threaded and Memcached isn’t. You also don’t need “built-in clustering” for Memcached; most languages have a consistent hashing library that makes running a cluster of Memcacheds relatively simple.

                                                      If you want a simple-to-operate, in-memory LRU cache, Memcached is the best there is. It has very few features, but for the features it has, they’re better than the competition.

                                                      1. 1

                                                        Most folks run multiple Redis per node (cpu minus one is pretty common) just as an FYI so the the “single process thing” is probably moot.

                                                        1. 5

                                                          N-1 processes is better than nothing but it doesn’t usually compete with multithreading within a single process, since there can be overhead costs. I don’t have public benchmarks for Memcached vs Redis specifically, but at a previous employer we did internally benchmark the two (since we used both, and it would be in some senses simpler to just use Redis) and Redis had higher latency and lower throughput.

                                                          1. 2

                                                            Yup. Totally. I just didn’t want people to think that there’s all of these idle CPUs sitting out there. Super easy to multiplex across em.

                                                            Once you started wanting to do more complex things / structures / caching policies then it may make sense to redis

                                                            1. 1

                                                              Yeah agreed, and I don’t mean to hate on Redis — if you want to do operations on distributed data structures, Redis is quite good; it also has some degree of persistence, and so cache warming stops being as much of a problem. And it’s still very fast compared to most things, it’s just hard to beat Memcached at the (comparatively few) operations it supports since it’s so simple.

                                                  1. 3

                                                    Changing to a BTreeMap instead of a HashMap in the LRU cache to optimize memory usage.

                                                    Why would a BTree map use less memory in rust?

                                                    1. 3

                                                      Hash maps usually try to have a lot of empty slots for performance, while afaik a BTree will usually just have the necessary nodes, right?

                                                      1. 1

                                                        I think it’s more about access patterns than just size. In a hash map the elements are essentially randomly jumbled about, whereas In a BTreeMap they can be sorted by time. The oldest elements will be closer together in memory and O(1) to find, which are both great news for a LRU cache.

                                                        1. 2

                                                          They didn’t say BTreeMap is faster, they said BTreeMap uses less memory. In fact, I very much doubt it was faster.

                                                          1. 0

                                                            I have no trouble believing it was faster for the workload. After all, that was the point of the article.

                                                      1. 2

                                                        I’ll continue hacking on my my ssh-chat bot which will send me notifications when i am mentioned on the chat.

                                                        1. 1

                                                          i have a pi and a meerkat(intel nuc). I run pihole, NFS share and a few long running sessions at home (ssh-chat, irc, etc.)

                                                          Thinking of setting up NextCloud or perkeep for data next.

                                                          1. 3

                                                            I’ve been saying this for years! I remember when it was a small group of really excited people did code in their spare time (it was a larger lift back then) and others had different hobbies.

                                                            Everyone did fine, and often those people who took breaks did better at work because they had time to retain what they learned, and also had ways to relate to non-technical people (a thing you frequently need to do as you level up) or even network internally and externally with other tech. people to learn and improve.

                                                            1. 2

                                                              completely agreed, coding in spare time and being good at writing code are orthogonal properties (you can do one without getting any close to the other).

                                                            1. 3

                                                              I’ve been thinking about this since i found out about zettelkasten method developed by Niklas Luhmann (on a comment on this excellent post You are your tools).

                                                              What I’ve come to realize is data organization in libraries and even by pre-compute dictionary designers could be very insightful on how we create indexes on data.

                                                              Reading more papers about data organization pre-computers is on my todo list, has one else explored this area?

                                                              1. 2

                                                                This particular line of questioning caused me to discover the idea of commonplacing, and the existence of Commonplace Books, which in turn impacted how I take notes and how I collect and organize my own thoughts into a knowledge base.

                                                                The main components are indexing, headings, and purposeful marginalia.

                                                                I have a digital knowledge base (in the form of plain text files that I have recently migrated to a github wiki) that is mostly technical / professional related, and an analog pen-and-paper knowledge base (in the form of a commonplace book) that is more personal interests.

                                                                1. 1

                                                                  A commonplace book is exactly what i was looking for, i’ve started using a mac app NVAlt for note taking and it’s amazing search and reduced the need for creating indexes manually.

                                                                  But i still want to try writing things down on a physical notebook! will definitely give John Loke’s method a try.

                                                              1. 5

                                                                Really liked the article, clear and concise! however i ended disagreeing with the disagreements.

                                                                • A strong stance against exceptions

                                                                Exception are good only for exceptional cases and not any non-favorable behavior. An http request failing is not an exceptional case but most systems treat it as such and create infrequent code paths which can lead to unforeseen failure conditions. (further anecdotal proof/opnion)

                                                                • John is quite in favor of writing comments

                                                                The post author’s stance is not in congruence with their agreement on deep modules. If a class/module has enough depth, it might require a why comment.

                                                                1. 2

                                                                  Thanks for the feedback and appreciate you voicing your disagreement.

                                                                  For exceptions, the book seemed to suggest going out of the way to throw them. I’m not that dogmatic and don’t mind them - as long as there’s good monitoring, and we follow a zero-exceptions policy. So I’m more on the mitigation side, than prevention, especially for backend software.

                                                                  For comments, I’m not a fan of inline comments. The “why” comments, especially at module/class level, I am definitely for. I really like how you put it: for deep classes, comments can probably explain a lot of their depth, helping maintenance greatly. Until I read your comment here, I did not think along this dimension, though. Thanks!

                                                                1. 2

                                                                  I’ve been wanting to write one in Golang backed by BoltDB or Badger for fun purposes. So far I’ve not got time to do so; but I hope I do soon and this article will be helpful.

                                                                  1. 1

                                                                    I’ve been thinking about the same thing. I also wanted to make it multi-tenant (only certain topics are visible depending on client credentials) and possibly distributable among many nodes.

                                                                    The biggest challenge right now is finding the time for it.

                                                                  1. 3

                                                                    A A4 piece of paper folded like a pocketMod to carry anywhere and Evernote to scan and keep. A Xiaomi pen.

                                                                    1. 1

                                                                      Do you scan them every day or at another cadence?

                                                                      1. 2

                                                                        It depends on the note. Some are short lived temporary ones. Others are more important. Those I scan as soon as I can. pocketMods are small and I tend to dispose them easily.

                                                                      2. 1

                                                                        Yes! I always keep one of these in my back pocket.

                                                                      1. 2

                                                                        My main contribution here is not a specific brand of notebook, but a specific practice: every bag I am likely to carry frequently has a notebook and a pen. Whenever I have something to write down, I have the tools.

                                                                        This means that I don’t have a chronological lab book or journal, because I write in whichever notebook I’ve brought with me.

                                                                        Oh also, a product review: I bought the Livescribe pen, and while the practice of digitising notebooks was useful, the pen did not last long. The plastic deteriorated and cracked where the barrel meets the tip, within a couple of months of ownership, rendering the pen useless.

                                                                        1. 1

                                                                          how do you review your notes? i would assume that you end up writing more in some notebooks than others hence finding related notes must be tough.

                                                                          1. 2

                                                                            Two factors that help:

                                                                            1. The bag I take is context dependent so it’s not random where a note ends up.
                                                                            2. The one in my laptop bag (which most often joins me in a work context) is loose leaf so those pages get files somewhere.
                                                                            1. 2

                                                                              interesting, you might find discbound notebooks helpful

                                                                        1. 3

                                                                          Come on, really? The throwaway copycat what’s-your-editor-setup posts were bad enough, but this is plainly offtopic. I hate to be a grinch but if there’s inflection point somewhere where this site just turns into HN or reddit, and I think we should sanction it even though it’s oh-so-tempting to chip in with our personal “setups”

                                                                          1. 5

                                                                            Not all memes are bad. We’ve had a grand total of 4 of these posts, and all of them very easily fall under software development. (Yes, even this notebook one, since I and others have or often do use notebooks to aid software development and programming)

                                                                            I agree that there is a tipping point beyond which they will no longer useful or relevant, and I think we’re close to having tapped out this well in this wave. Sometimes it’s nice to let loose a bit, however, knowing that it will pass.

                                                                            I could see a monthly or quarterly “What is your (work|non-work) development setup” post also being a nice addition to our periodic book recommendations. I don’t think it merits the weekly nature of “what are you doing”, since development setups aren’t changing that often.

                                                                            1. 3

                                                                              It’s on the ask tag; if asking questions is a topic, then it seems on topic. Maybe you want to get rid of ask, or just want to filter it out? I don’t want you to have to see this posts if you don’t want to.

                                                                              1. 5

                                                                                I bet you’re fun at parties. The contrarian gets the upvotes, but think carefully about whether or not you want to reward this kind of behavior on Lobsters.

                                                                                1. -1

                                                                                  Thanks for the personal insult, I appreciate it. I did not actually post this just to be contrarian and score points, as you’ve assumed.

                                                                                  Speaking of rewarding behavior: no, I don’t want to see the rewarding of what are essentially meme posts, and I don’t want this site to gradually veer away to where the front page is meme posts and offtopic discussion. We have reddit for the former and HN for the latter. This thread is mostly a discussion of paper notebooks and favorite pens. I’m sure there’s a subreddit for that.

                                                                                2. 2

                                                                                  but this is plainly offtopic.

                                                                                  Asking lobsters about a tool that they use for/during development in my opinion is not off topic with respect to the tags used for the post. But the mods can clarify that. We’ve discussed this exact topic many times over the years and even development tool generally, why is it bad?

                                                                                  I first learned about Bullet Journals from a comment on lobste.rs and it improved the way i work & write software by a lot.

                                                                                1. 4

                                                                                  What: I switched to zsh 4 years ago and dumped my custom bash config in-favor of oh-my-zsh.

                                                                                  Why: Had to setup multiple new installs (due to new releases, server upgrades, etc.) managing my bashrc was getting tedious and oh-my-zsh was way nicer than what i could get by spending the amount of time i had for bash.

                                                                                  1. 3

                                                                                    In my only experience architecting a large C# application, I never reached a satisfactory conclusion on this topic.

                                                                                    In practice, singleton never seemed to solve any of the issues that led to my exploring it, instead acting as a temporary tonic to my OOP design anxieties while obscuring implicit behavior and making my application harder to reason about.

                                                                                    My final design in said application had me explicitly instantiating at the main entry point a small number of objects representing legitimately global systems (datastore, audio controller, etc.) and explicitly passing those objects as parameters until functions became too yucky, then refactoring to wrap them in something akin to a master application configuration object with a rigid interface.

                                                                                    The dissatisfaction I had and have with this final implementation seems to be aesthetic, like it violates some deep OOP principles (likely), but which aren’t solved with singleton.

                                                                                    Using singleton made me feel clever as a “consumer” of my own singleton each time I wrote a function call, but made the program harder to reason about because the implicit behavior was still implicit, just implicitly implicit instead of explicitly implicit.

                                                                                    1. 4

                                                                                      disclaimer: these are observations from the code bases I’ve worked on, i don’t know your specific situation

                                                                                      explicitly passing those objects as parameters until functions became too yucky

                                                                                      Every time I’ve reached this situation the fault was bad abstractions. The methods were doing too much or needed to be aware of too many things. Later on during development, these also emerged to be the spots where it was difficult to hold the complete logic in my head.

                                                                                      even when said state is legitimately global

                                                                                      There is always global state the point is that the lower level code shouldn’t be aware of it or depend on it. The lower level code should only know what it was provided.

                                                                                      I’ve try very hard to not write any singleton classes but working with a large team with tons of code, i semiregularly stumble upon something that resembles a singleton, it might look like snippit 1 or 2 from the article and I’ll refactor it to snippit 5.

                                                                                      I am not sure if this is useful, it took me a while to realize that patterns are not tools to solve a problem they are categories of solutions. If you end up using a solution that looks like a pattern refactor the code to fix the problems that the pattern frequently has/prevents.

                                                                                      1. 3

                                                                                        every time I’ve reached this situation the fault was bad abstraction

                                                                                        Undoubtedly true in my situation. The most hair-pulling breakdowns in coherent design always appeared in sub-systems I had the least experience with.

                                                                                        Audio is a useful example. If the audio controller was told to play a sound, how and when would it actually play? What if something else was already playing? Did the controller need to understand the caller and why the sound was triggered, and thus depend on every potential caller? Or if the caller passed the details, didn’t that just flip the dependency and unravel the encapsulation of audio logic?

                                                                                        Presumably someone with deeper experience would have started from some sort of informed design, but I bolted on sound after everything else and learned that you had to think about such things only when I stumbled over them for the first time.

                                                                                        1. 2

                                                                                          The most hair-pulling breakdowns in coherent design always appeared in sub-systems I had the least experience with.

                                                                                          Absolutely, this happens all the time.

                                                                                          learned that you had to think about such things only when I stumbled over them for the first time.

                                                                                          i am still pretty bad at this, so i first think, then sketch out what i would do and then do it 2-3 times. it’s a little slow in beginning but keep development faster in the long term.

                                                                                      2. 1

                                                                                        My final design in said application had me explicitly instantiating at the main entry point a small number of objects representing legitimately global systems (datastore, audio controller, etc.) and explicitly passing those objects as parameters…

                                                                                        I do something like this in C# using the Ninject dependency injection framework. It offers various scopes for those to be injected in (e.g., singleton, thread, ASP.NET request, etc.). This way, you don’t really have to write any singleton classes as such, and your calling code doesn’t have to do anything special other than accept dependency injection. It makes testing easier than with an actual singleton, too.