Re: Keeping Track of a game's storyline/objectivs

to quote the article posted above:

I hear this a lot, often from programmers who don’t actually know the details of the pattern. They have a default assumption that anything that smells like a “design pattern” must involve piles of classes and indirection and other creative ways of squandering CPU cycles.

The Observer pattern gets a particularly bad rap here because it’s been known to hang around with some shady characters named “events”, “messages”, and even “data binding”. Some of those systems can be slow (often deliberately, and for good reason). They involve things like queuing or doing dynamic allocation for each notification.

This is why I think documenting patterns is important. When we get fuzzy about terminology, we lose the ability to communicate clearly and succinctly. You say, “Observer”, and someone hears “Events” or “Messaging” because either no one bothered to write down the difference or they didn’t happen to read it.

That’s what I’m trying to do with this book. To cover my bases, I’ve got a chapter on events and messages too: Event Queue.
But, now that you’ve seen how the pattern is actually implemented, you know that isn’t the case. Sending a notification is simply walking a list and calling some virtual methods. Granted, it’s a bit slower than a statically dispatched call, but that cost is negligible in all but the most performance-critical code.

I find this pattern fits best outside of hot code paths anyway, so you can usually afford the dynamic dispatch. Aside from that, there’s virtually no overhead. We aren’t allocating objects for messages. There’s no queueing. It’s just an indirection over a synchronous method call.

plus you can't say its to slow if you've never implemented it and tested it out. try it and report back.

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Munawar via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Munawar via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Munawar via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Munawar via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : NicklasMCHD via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector

Reply via email to