On Mar 27, 8:25 am, TreKing treking...@gmail.com wrote:
Spawning off the Dialog box without title thread to discuss the pros and
cons of storing Context as a member vs passing a parameter. Here's the last
bit of the discussion from that thread:
Ugh, sorry, I discussed this in the original
MM == Mark Murphy mmur...@commonsware.com writes:
... I'd further qualify that as ... a cached Context (if needed) should
be
an Application object reference, rather than a local, short-lived
Context.
Does extending the Application class to save the context and providing a
static
On Mon, Mar 28, 2011 at 9:59 AM, Jake Colman col...@ppllc.com wrote:
MM == Mark Murphy mmur...@commonsware.com writes:
... I'd further qualify that as ... a cached Context (if needed) should
be
an Application object reference, rather than a local, short-lived
Context.
Does
28.03.2011 17:59, Jake Colman пишет:
Does extending the Application class to save the context and providing a
static method to access that context an appropriate solution as well?
I don't see any problems with:
class JakesApplication extends Application /* indirectly extends Context
*/ {
Oh, I see where you're going. Yeah, that should be OK. I've often
wondered why they didn't bother with a static getter on Application
itself, if the thing is going to live as long as a static.
On Mon, Mar 28, 2011 at 10:10 AM, Kostya Vasilyev kmans...@gmail.com wrote:
28.03.2011 17:59, Jake
Actually, I had declared gInstance as a variable of ttype Context and
not of type JakesApplication. I guess both are correct except that
JakesApplication is more type-specific and better programming style?
MM == Mark Murphy mmur...@commonsware.com writes:
MM Oh, I see where you're going.
On Mon, Mar 28, 2011 at 10:27 AM, Jake Colman col...@ppllc.com wrote:
Actually, I had declared gInstance as a variable of ttype Context and
not of type JakesApplication. I guess both are correct except that
JakesApplication is more type-specific and better programming style?
And safer. You do
On Sun, Mar 27, 2011 at 10:16 AM, Kostya Vasilyev kmans...@gmail.com
wrote:
27.03.2011 19:05, TreKing пишет:
Do you have a good example of when storing a Context like this is a good
idea? I'm just curious.
I do. Singletons.
Or, to use a more simple name, manager or utility classes that
27.03.2011 19:27, TreKing пишет:
Do you have something more concrete? :-)
I was already being quite specific.
Any Singleton, manager, or utility class can take Context as a
parameter for the functions it needs it for, making it clear to the
user of the API that a Context is needed for that
On Sun, Mar 27, 2011 at 11:58 AM, Kostya Vasilyev kmans...@gmail.com wrote:
Any Singleton, manager, or utility class can take Context as a parameter
for the functions it needs it for, making it clear to the user of the API
that a Context is needed for that functionality
Sure, that's another
27.03.2011 20:17, Mark Murphy пишет:
Singletons, manager, or utility classes should not be caching a
Context.
They can and should if needed or wanted. However ...
At most, they should be caching an Application, to prevent
people from accidentally caching short-lived Contexts (e.g.,
On Sun, Mar 27, 2011 at 12:30 PM, Kostya Vasilyev kmans...@gmail.com wrote:
27.03.2011 20:17, Mark Murphy пишет:
Singletons, manager, or utility classes should not be caching a
Context.
They can and should if needed or wanted. However ...
At most, they should be caching an Application, to
We're in agreement then :)
I like how you use Application class in method signature to ensure
correctness (although I tend to call getApplicationContext inside
MySingleton).
-- Kostya
27.03.2011 20:36, Mark Murphy пишет:
My point was that you should not have:
class MySingleton {
On Sun, Mar 27, 2011 at 10:58 AM, Kostya Vasilyev kmans...@gmail.comwrote:
Any Singleton, manager, or utility class can take Context as a parameter
for the functions it needs it for, making it clear to the user of the API
that a Context is needed for that functionality
Sure, that's another
27.03.2011 21:14, TreKing ?:
On Sun, Mar 27, 2011 at 10:58 AM, Kostya Vasilyev kmans...@gmail.com
mailto:kmans...@gmail.com wrote:
Any Singleton, manager, or utility class can take Context as a
parameter for the functions it needs it for, making it clear
to the user
15 matches
Mail list logo