I’ve been doing a lot of thinking lately about how all of this “code” stuff can be written so that it is most approachable and maintainable. I’m still investigating this line of thinking, but I think some strides have been made over the past few months.
One of my guiding principles has been a strong Delegate Pattern adoption. It supports something I call “positive control” in my systems. All of this is a fancy way of saying it’s most logical if the part of a program that asks another part to do some work for it is also the one listening for the answer. Message and process chaining can result in some very elegant code, but that elegance comes at a very high cost for maintainability.
As I move deeper into a large-scale enterprise application, the more I have had to flex on this theory. Let me make it clear that I’m not under any belief that any pattern or mechanism is right for all scenarios. We have had plenty of opportunities to adjust our patterns as we have moved along this interesting path. But we have always been able to fit things back into the general definition of SOOJS and it’s principles.
It’s become clear, however, that the great benefits we find using an Observer pattern far outweigh any of the negatives brought by it’s complexity. This has become clear enough that I have decided to outfit our entire system with a standard Observer pattern — entirely removing the more restrictive Delegate pattern. And I still feel a little concern over this change. Something in me says that this is the first time I’ve returned the devil’s gaze across the ballroom floor. Will this lead to the inevitable twisted dance I have tried to steer away from this whole time?
At its simplest, I am allowing as many “listeners” to any object as have interest in subscribing. It still follows a reasonable strict enrollment and messaging pattern. I am not willing to move to a more simplistic and uncontrollable event binding system. That is the full-blown Samba.
For now, Mr. Devil, you will have to suffice with the slight crack at the corner of my mouth. It’s not a smile, and I assure you, I am not flirting.