[google-appengine] Re: Is it really bad to define global variables?

2010-08-04 Thread Nacho Coloma
On Jul 30, 8:47 pm, "Ikai L (Google)" wrote: > it sounded like he wanted to do it on > a per query basis - and there'd be all the problems with global mutable > state, concurrency, etc. Just for the sake of completeness, this case is usually implemented using a static ThreadLocal instance. But I

Re: [google-appengine] Re: Is it really bad to define global variables?

2010-07-30 Thread Jeff Schwartz
Yup, yup! I'd bet there's a good design pattern for this. I'd really like to see more online docs specifically dealing with design pattern implementations geared towards the different aspects and intricacies of appengine. The docs could even be tied via links to some of the great Google IO videos

Re: [google-appengine] Re: Is it really bad to define global variables?

2010-07-30 Thread Ikai L (Google)
A static isn't global, but in the OP's use case, it's way out of the scope of what he needs to do, which is to pass around objects. Rather than passing the object around, it sounded like he just wanted to stash the object into global/static scope and pull it out. There are certainly use cases for t

Re: [google-appengine] Re: Is it really bad to define global variables?

2010-07-30 Thread Ikai L (Google)
I avoided this thread because I wanted to see some code first. It sounded like the original poster wanted to use globals in a non-thread safe way. Statics are not a bad thing, but using globals to pass state around that is only useful in local scope is very, very bad. On Fri, Jul 30, 2010 at 7:11

Re: [google-appengine] Re: Is it really bad to define global variables?

2010-07-30 Thread Jeff Schwartz
I'm not sure what you mean by 'globals'. Static fields are not global - they must be referenced using a class name. On Fri, Jul 30, 2010 at 1:23 PM, Ikai L (Google) wrote: > I avoided this thread because I wanted to see some code first. It sounded > like the original poster wanted to use globals

Re: [google-appengine] Re: Is it really bad to define global variables?

2010-07-30 Thread Jeff Schwartz
Hi Stephen, I hope I wasn't perceived as someone trying to be right. I was only trying to prevent other readers from being misinformed. Modern programming languages offer a lot of useful 'tools' that empower the kinds of programming constructs that at one time were only dreamed of. It would be wa

[google-appengine] Re: Is it really bad to define global variables?

2010-07-29 Thread Stephen Johnson
Yes Jeff, you are correct, constant values are safe to use. On Jul 29, 7:23 pm, Jeff Schwartz wrote: > Stephen > > With all due respect, you are stating the obvious and the use case you > present is like a text book example of last in first out/race ahead > condition. Perhaps if the coder had dec

Re: [google-appengine] Re: Is it really bad to define global variables?

2010-07-29 Thread Jeff Schwartz
Stephen With all due respect, you are stating the obvious and the use case you present is like a text book example of last in first out/race ahead condition. Perhaps if the coder had declared the static variable final and initialized it in a static constructor it would have prevented multiple assi

[google-appengine] Re: Is it really bad to define global variables?

2010-07-29 Thread Stephen Johnson
Hi Jeff (and possible Bill if you're using Java and not Python (not sure from the question since I don't know Python)) (Assuming Java) Using static variables could cause all kinds of trouble if proper care is not taken to limit their accessibility since they are shared and all requests that are bei

[google-appengine] Re: Is it really bad to define global variables?

2010-07-29 Thread Tim Hoffman
Hi On Jul 29, 11:32 pm, Jeff Schwartz wrote: > I wasn't the original poster but I was curious about your caution regarding > class static fields. > Sorry missed that. Having not done any development with java on appengine all my development (and hence statements about module level caches) > Wh

Re: [google-appengine] Re: Is it really bad to define global variables?

2010-07-29 Thread Jeff Schwartz
I wasn't the original poster but I was curious about your caution regarding class static fields. Which Python framework are you using if you don't mind me asking? Jeff On Thu, Jul 29, 2010 at 10:49 AM, Tim Hoffman wrote: > Hi > > On Jul 29, 8:40 pm, Jeff Schwartz wrote: > > Hi Tim. > > > > H

[google-appengine] Re: Is it really bad to define global variables?

2010-07-29 Thread Tim Hoffman
Hi On Jul 29, 8:40 pm, Jeff Schwartz wrote: > Hi Tim. > > Help me out here 'cause I don't understand what problem you see with storing > a value in a static field? Wouldn't have a clue. I don't use java on appengine. You didn't mention in your original post you where specifically talking about

Re: [google-appengine] Re: Is it really bad to define global variables?

2010-07-29 Thread Jeff Schwartz
Hi Tim. Help me out here 'cause I don't understand what problem you see with storing a value in a static field? As far as I know (and I am limiting my discussion here to Java and servlets) objects are not persisted across http requests unless they are serializable and stored in session or in memc

[google-appengine] Re: Is it really bad to define global variables?

2010-07-29 Thread Tim Hoffman
The biggest problem I see with storing the value at a class/module level is you really need to make sure you clean up after yourself, otherwise the value may still be set when the next request is processed and that value may not be appropriate. I would personally always grab/cache values in reques