Qfwfq Posted March 6, 2006 Report Posted March 6, 2006 Uhm, but... an instance allocated by new ain't a global! A static member of a class is a global except that it's in the class'es namespace. BTW when I do a certain type of quick coding I just adore declaring globals galore :hyper:, more efficient and less worry of having to pass values around in parameters! C/C++ were certainly concieved a touch more for monolithic programming but it's not just a matter of late linkage, that's even somewhat a platform issue which the JVM makes standard for Java. There's an old legend that elderly programmers are in the habit of calling the linker the "loader" which suggests something to me... :steering: Quote
alexander Posted March 7, 2006 Report Posted March 7, 2006 yeah i wanted to post but it was late yesterday, you are better off using a gcc based compiler for any c++ development then the VS, at least gcc is standard compliant, and generates cleaner code then VS, there is less junk to deal with and most code online (for windows) will compile on something like DevCpp and will most likely fail with VS cuz their total incompliance with the standards...I personaly prefer PHP to Java, cuz you can do more stuff, and many times a lot better and faster with PHP rather then Java, its a total hybrid so it makes the best of 2 worlds, oh and it has a perl regular expression engine, which is crazified, makes dealing with text not such a bad thing, and there is less of an overhead with PHP's engine vs JVM... but i'm sure buffy was expecting me to say that :confused: Oh and dammit people, learn not to use globals, they are such weak points in your programs, unless totally needed it is a bad programming practice to do it, so dont unless totally needed... Quote
Buffy Posted March 7, 2006 Report Posted March 7, 2006 Uhm, but... an instance allocated by new ain't a global! Well not techincally, but if you just start off object-orientedly, you've got your main program instance and anything in there is global to everything that is inside it, so its uh, "global" for all intents and purposes... :hyper:C/C++ were certainly concieved a touch more for monolithic programming but it's not just a matter of late linkage...Well, yeah, you'd need to change the calling protocol, but that *is* a compiler/linker issue, and you'd be cutting yourself off from being able to link old libraries, but I say, so what?and there is less of an overhead with PHP's engine vs JVM... but i'm sure buffy was expecting me to say that Of course! But with all this horsepower, who cares about efficiency? I'm usually I/O bound on the db access anyway... :confused:Oh and dammit people, learn not to use globalsOh amen alex! Globals considered harmful,Buffy Quote
alexander Posted March 7, 2006 Report Posted March 7, 2006 hey, whatever suits your needs, Buffy, at least its a Sun product... Sun is cool :confused: Quote
Qfwfq Posted March 7, 2006 Report Posted March 7, 2006 Right Alex, globals are a pain in the neck in a complex project, 'specially if names are obscure, for analysing previous code, including your own from years back, but when you're talking about one instance values that are central to the whole project and need to be used by many functions, passing them around in parameters can be no better if not worse. A parameter is itself local to the proc if it isn't a ref but, in any case, who is it really? :hyper: You often need to trace through the call stack to be sure and of course that might not be the same for all possible calls. Old saying: it's 6 of 1 & 1/2 dozen of the other... :confused: you've got your main program instance and anything in there is global to everything that is inside it, so its uh, "global" for all intents and purposes...But that doesn't make for nearly as easy access as does a static member of some class, which may even be ad hoc for global variables and even an interface for global constants. It's enough for any class to import these, you don't need to have a valid pointer, the class name is enough and, if it's long and needed more than once, I usually declare: GlobalVariables glb; without even assigning anything to it, you can write glb.totRequestsPending or whatever. :singer: Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.