Re: [android-developers] Re: Global Variables

2011-03-14 Thread Greg Donald
On Sun, Mar 13, 2011 at 12:25 PM, Brill Pappin br...@pappin.ca wrote: I think Java still has a variant of the GOTO, but I have never seen it used once in about 18 years of java development! Just because you don't see them doesn't mean they are not there. They have always been present in every

Re: [android-developers] Re: Global Variables

2011-03-13 Thread Dianne Hackborn
That's strange, it works for me. On Sat, Mar 12, 2011 at 11:42 PM, Indicator Veritatis mej1...@yahoo.comwrote: I get no such project when I try to go to your link. On Mar 12, 1:05 am, Dianne Hackborn hack...@android.com wrote: Oh good lord, there is nothing intrinsically evil about globals

[android-developers] Re: Global Variables

2011-03-13 Thread William Ferguson
Dianne, I also get 404 No such project On Mar 13, 6:42 pm, Dianne Hackborn hack...@android.com wrote: That's strange, it works for me. On Sat, Mar 12, 2011 at 11:42 PM, Indicator Veritatis mej1...@yahoo.comwrote: I get no such project when I try to go to your link. On Mar 12, 1:05

[android-developers] Re: Global Variables

2011-03-13 Thread Brill Pappin
I think Java still has a variant of the GOTO, but I have never seen it used once in about 18 years of java development! - Brill Pappin On Mar 9, 6:01 pm, Kostya Vasilyev kmans...@gmail.com wrote: Oh, come on, guys, it's not that bad :) Sometimes I even miss a good old-fashioned goto. --

[android-developers] Re: Global Variables

2011-03-13 Thread Brill Pappin
public static final apiKey = xxx; now you can access it as: String key = globalVars.apiKey; However, not that this is not a variable, its a constant. According to convention, it should be in upper case: public static final API_KEY = xxx; - Brill Pappin On Mar 9, 8:11 pm, David

[android-developers] Re: Global Variables

2011-03-13 Thread Brill Pappin
That is a very good article and entertaining to read.. every one of us should be reading it and understanding it before we're allowed to call ourselves programmers :) - Brill Pappin On Mar 9, 8:35 pm, fadden fad...@android.com wrote: On Mar 9, 2:13 pm, TreKing treking...@gmail.com wrote: On

Re: [android-developers] Re: Global Variables

2011-03-12 Thread Dianne Hackborn
Oh good lord, there is nothing intrinsically evil about globals or singletons. Just don't abuse them. For example, say I want to do a query on the package manager about a set of applications that are available. If I stick this as local data inside of a particular activity, then every time the

[android-developers] Re: Global Variables

2011-03-12 Thread Indicator Veritatis
I get no such project when I try to go to your link. On Mar 12, 1:05 am, Dianne Hackborn hack...@android.com wrote: Oh good lord, there is nothing intrinsically evil about globals or singletons.  Just don't abuse them. For example, say I want to do a query on the package manager about a set

[android-developers] Re: Global Variables

2011-03-11 Thread Indicator Veritatis
David- I am surprised anyone can even think to ask your question. The whole POINT of Java is to provide support for object oriented methodology, even making object disoriented methodology difficult. Yet you are asking about the very antithesis of object oriented programming, the infamous global.

Re: [android-developers] Re: Global Variables

2011-03-11 Thread David Williams
Yes, I got the answer to this question from other people who didn't phrase their answer in a manner like you did. Thanks though. David Williams Check out our WebOS mobile phone app for the Palm Pre and Pixi:

Re: [android-developers] Re: Global Variables

2011-03-11 Thread Brill Pappin
Singleton is also one to be avoided however... just like global vars :) However, as we're working on a (sort of) limited device, Singletons are a way of life. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email

[android-developers] Re: Global Variables

2011-03-10 Thread Kenny Riddile
On 3/9/2011 7:35 PM, TreKing wrote: On Wed, Mar 9, 2011 at 4:30 PM, Kenny Riddile kfridd...@gmail.com mailto:kfridd...@gmail.com wrote: Assuming the singleton is modifiable via its interface, then for all intents and purposes, yes, they are. Again, no. Singleton is a design pattern

Re: [android-developers] Re: Global Variables

2011-03-10 Thread TreKing
On Thu, Mar 10, 2011 at 9:11 AM, Kenny Riddile kfridd...@gmail.com wrote: Perhaps my blanket statement was to simplistic. Not ALL singletons are global variables. Also, not all globals are variables (globally accessible static constants for example). However, all STATEFUL singletons are

[android-developers] Re: Global Variables

2011-03-10 Thread Kenny Riddile
On 3/10/2011 10:41 AM, TreKing wrote: Hmm, perhaps this is semantics at this point. I don't think a singleton is a global, as it's usually a private member that is statically accessible. However, there is global access, of course. If it's a single piece of state that's accessible globally,

Re: [android-developers] Re: Global Variables

2011-03-10 Thread TreKing
On Thu, Mar 10, 2011 at 10:03 AM, Kenny Riddile kfridd...@gmail.com wrote: Anyways, this has gotten a bit off-topic from the OP's original question, and for that, I apologize :) Thread title: Global Variables - seems quite on topic. It's not like we're exchanging cookie recipes =P

Re: [android-developers] Re: Global Variables

2011-03-10 Thread Kostya Vasilyev
10.03.2011 19:03, Kenny Riddile ?: No, but in terms of clarity, readability, and ease of debugging, there is a *huge* difference in using a singleton to modify some globally accessible object versus a classic global. To me, the third option of don't use either one is almost always

[android-developers] Re: Global Variables

2011-03-09 Thread Kenny Riddile
On 3/9/2011 3:41 PM, David Williams wrote: All, What is the best way of going about setting up global variables? There will be like 5-6 global variables that I would like to set when my app is launched that are then available for any code anywhere in my app. I did something similar to this

[android-developers] Re: Global Variables

2011-03-09 Thread Kenny Riddile
On 3/9/2011 4:26 PM, TreKing wrote: On Wed, Mar 9, 2011 at 3:15 PM, David Williams dwilli...@dtw-consulting.com mailto:dwilli...@dtw-consulting.com wrote: That said, why avoid them like the plague? Global variables are one of those things, like Singletons, that on the surface seem to make

Re: [android-developers] Re: Global Variables

2011-03-09 Thread TreKing
On Wed, Mar 9, 2011 at 4:10 PM, Kenny Riddile kfridd...@gmail.com wrote: Singletons are global variables. Uh ... no ... no they're not. - TreKing http://sites.google.com/site/rezmobileapps/treking

Re: [android-developers] Re: Global Variables

2011-03-09 Thread Scott Davies
On 11-03-09 5:30 PM, Kenny Riddile kfridd...@gmail.com wrote: On 3/9/2011 5:13 PM, TreKing wrote: On Wed, Mar 9, 2011 at 4:10 PM, Kenny Riddile kfridd...@gmail.com mailto:kfridd...@gmail.com wrote: Singletons are global variables. Uh ... no ... no they're not.

Re: [android-developers] Re: Global Variables

2011-03-09 Thread Kostya Vasilyev
What if the Singleton is a Facade or a Mediator? :) 10.03.2011 1:44 пользователь Scott Davies code-p...@hotmail.com написал: On 11-03-09 5:30 PM, Kenny Riddile kfridd...@gmail.com wrote: On 3/9/2011 5:13 PM, TreKing wrote: On Wed, Mar 9, 2011 at 4:10 PM, Kenny Riddile kfridd...@gmail.com

[android-developers] Re: Global Variables

2011-03-09 Thread fadden
On Mar 9, 2:13 pm, TreKing treking...@gmail.com wrote: On Wed, Mar 9, 2011 at 4:10 PM, Kenny Riddile kfridd...@gmail.com wrote: Singletons are global variables. Uh ... no ... no they're not. I think this about covers it: http://sites.google.com/site/steveyegge2/singleton-considered-stupid

Re: [android-developers] Re: Global Variables

2011-03-09 Thread TreKing
On Wed, Mar 9, 2011 at 4:30 PM, Kenny Riddile kfridd...@gmail.com wrote: Assuming the singleton is modifiable via its interface, then for all intents and purposes, yes, they are. Again, no. Singleton is a design pattern whose purpose is to simplify and control access to a an object for which

Re: [android-developers] Re: Global Variables

2011-03-09 Thread Justin Anderson
I agree with TreKing. Thanks, Justin Anderson MagouyaWare Developer http://sites.google.com/site/magouyaware On Wed, Mar 9, 2011 at 5:35 PM, TreKing treking...@gmail.com wrote: On Wed, Mar 9, 2011 at 4:30 PM, Kenny Riddile kfridd...@gmail.com wrote: Assuming the singleton is modifiable via

[android-developers] Re: Global variables

2009-03-28 Thread Tseng
Unlike in C/C++ or PHP you can't have global variables in Java (or C#). The closest thing to a global is a public static variable. for example class YourActivity extends Activity { public static boolean bMyBoolean; } Now you could access it with if(YourActivity.bMyBoolean) { // Do