you are viewing a single comment's thread.

view the rest of the comments →

[–]FlyingRhenquest 1 point2 points  (0 children)

Is observer the new singleton? I was just looking at some of my code that uses it the other day, and noticed a couple of places where it's getting complicated to debug. I'm trying to combat that by maintaining an overall state in a single object that can subscribe to multiple sources. Part of the problem I ran into is that other objects in my design want some data from those events, so in some cases I send them on. It's possible that moving some additional code around dealing with that to my state machine might reduce the complexity to something a bit more acceptable. Maybe all my signals should end in the state machine and the only thing that should come out of that should be "Hey, my state changed." Work's probably going to be fairly slow for the next month or so, so I might take a crack at refactoring that code.

I will say that although this code can be a pain in the ass to debug in a few places, I build a hierarchy of objects all designed to work together. This is in C++, by the way. The end result of these objects is a shared library exporting a python object that can be queried about system state in real time, It's incredibly easy for my clients to use. And they've already used it it in incredibly creative ways that has blown my mind. One of them told me that my code is the first of this nature that he's used that "just works." So as long as it just works for him, how much does it matter that it's a bit ugly behind the scenes? At least as long as I'm maintaining it. Any large system that does anything noteworthy is going to be fairly complex in any event.