Re: [Flashcoders] Singleton lookups vs Events ...
Performance optimization is nice and all, but... how often will that happen in a frame? Once? A few hundred times? Then go with whatever is the easiest to understand, because you're still at fractions of a milisecond. Try it -- just time how long it takes to call a getInstance method a few thousand times or send as many events. I'd expect the Singletons to be slightly faster, especially if a new event object would have to be instantiated each time, but then, I don't see the relation between them and events. Perhaps you could give an example of a situation where both would be equaly valid options? If you have a situation where it would actually make a measurable difference in performance, then you'd probably want to go without any of the two. Mark On Wed, Sep 3, 2008 at 3:16 PM, S0 F1 <[EMAIL PROTECTED]> wrote: > Any thoughts on whether it's more efficient (in terms of development and > player performance) to use Singleton's (with static public 'getInstance' or > such) instead of Event's when developing mid-sized applications? (for > classes that *are* Singleton's of course). Asking this in regards to when > you know no other class needs notification. > > It seems a lot cleaner in terms of code (not having to create and listen for > events). Just a direct call - but what about performance speed, etc. > > Is this good practice. > > Cheers. > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Singleton lookups vs Events ...
*I like events - but I am no computer scientist. Events allow flexibility. * On Wed, Sep 3, 2008 at 9:16 AM, S0 F1 <[EMAIL PROTECTED]> wrote: > Any thoughts on whether it's more efficient (in terms of development and > player performance) to use Singleton's (with static public 'getInstance' or > such) instead of Event's when developing mid-sized applications? (for > classes that *are* Singleton's of course). Asking this in regards to when > you know no other class needs notification. > > It seems a lot cleaner in terms of code (not having to create and listen > for > events). Just a direct call - but what about performance speed, etc. > > Is this good practice. > > Cheers. > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Singleton lookups vs Events ...
>From a performance perspective, using fewer listeners in favor of instance references will always be a performance gain since listeners take up way more system resources than object references do. From an architecture/design pattern perspective though, I can't say whether it's better or not, it depends more on the type of app you are building and the type of architecture you put in place to support it. Not having as many events (either bubbling or non-bubbling) in favor of instances (i.e. SingletonClass.getInstance()) can get very messy and buggy if you don't do it right. I've found using a mix of both in the right places to be the best methodology in terms of overall design. Jason Merrill Bank of America Enterprise Technology & Global Risk L&LD Instructional Technology & Media Join the Bank of America Flash Platform Developer Community Are you a Bank of America associate interested in innovative learning ideas and technologies? Check out our internal Innovative Learning Blog & subscribe. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of S0 F1 Sent: Wednesday, September 03, 2008 9:17 AM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Singleton lookups vs Events ... Any thoughts on whether it's more efficient (in terms of development and player performance) to use Singleton's (with static public 'getInstance' or such) instead of Event's when developing mid-sized applications? (for classes that *are* Singleton's of course). Asking this in regards to when you know no other class needs notification. It seems a lot cleaner in terms of code (not having to create and listen for events). Just a direct call - but what about performance speed, etc. Is this good practice. Cheers. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Singleton lookups vs Events ...
- Original Message - From: "S0 F1" <[EMAIL PROTECTED]> To: Sent: Wednesday, September 03, 2008 2:16 PM Subject: [Flashcoders] Singleton lookups vs Events ... Any thoughts on whether it's more efficient (in terms of development and player performance) to use Singleton's (with static public 'getInstance' or such) instead of Event's when developing mid-sized applications? (for classes that *are* Singleton's of course). Asking this in regards to when you know no other class needs notification. It seems a lot cleaner in terms of code (not having to create and listen for events). Just a direct call - but what about performance speed, etc. Is this good practice. Direct calls? No, because you are binding one class to another and are building restrictions into your classes that mean they are less reusable in the future. What if you need another class to respond? You need to add another call to class C from class A because class A was built only to call class B. With events class A issues the event and remains unchanged. I don't understand the supposed correlation between sinletons and avoiding events. Perhaps it's because static classes/singletons are accessible without having to access an instance created elsewhere? Paul Cheers. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders