posted 17 years ago
Several questions need to be answered before you can determine if you can share a common instance of this class.
1. What is the lifetime of the object created in these methods? (Is it used after the method exists? Are any references to the object kept?)
2. Is the object expensive to create? Does it use a lot of memory? (What benefit are you trying to get from reusing the object?)
3. Could the single instance be accessed from multiple threads and, if so, is it thread-safe?
4. What are the implications of this class living through multiple invocations? Does it's state need to be reset? Can it be reset?
Some objects are very cheap to create and it's faster to create them rather than clean up after each use.