static

Java Static

Duplicate: http://stackoverflow.com/questions/413898/what-does-the-static-keyword-do-in-java I've read this post already. What does the "static" keyword in a method do? I remember being told that static != clingy...but that is pretty much all I know about this keyword. ...

How to get a Static property with Reflection

So this seems pretty basic but I can't get it to work. I have an Object, and I am using reflection to get to it's public properties. One of these properties is static and I'm having no luck getting to it. Public Function GetProp(ByRef obj As Object, ByVal propName as String) as PropertyInfo Return obj.GetType.GetProperty(propName)...

Are static fields open for garbage collection?

Given an hypothetical utility class that is used only in program setup: class MyUtils { private static MyObject myObject = new MyObject(); /*package*/static boolean doStuff(Params... params) { // do stuff with myObject and params... } } will myObject be garbage collected when it is no longer being used, or will it stic...

Is returning a pointer to a static local variable safe?

I'm working with some code that widely uses the idiom of returning a pointer to a static local variable. eg: char* const GetString() { static char sTest[5]; strcpy(sTest, "Test"); return sTest; } Am I right in thinking that this is safe? PS, I know that this would be a better way of doing the same thing: char* const GetString...

Thread safety of static blocks in Java

Let's say I have some Java code: public class SomeClass { static { private final double PI = 3.14; private final double SOME_CONSTANT = 5.76; private final double SOME_OTHER_CONSTANT = 756.33; } //rest of class } If a thread is instantiating an instance of SomeClass and is in the middle of initializi...

C# .net Mnemonics and use in general.

I'm just starting out with C# and to me it seems like Microsoft Called their new system .Net because you have to use the Internet to look everything up to find useful functions and which class they stashed it in. To me it seems nonsensical to require procedure/functions written and designed to stand alone ( non instantiated static obje...

Is it possible to create static classes in PHP (like in C#)?

I want to create a static class in PHP and have it behave like it does in C#, so Constructor is automatically called on the first call to the class No instantiation required Something of this sort... static class Hello { private static $greeting = 'Hello'; private __construct() { $greeting .= ' There!'; } p...

Destruction order of static objects in C++

Can I control the order static objects are being destructed? Is there any way to enforce my desired order? For example to specify in some way that I would like a certain object to be destroyed last, or at least after another static onject? Cheers, Gal ...

In ASP.Net MVC, is using static methods to look up cached objects on views bad practice?

I am creating a portal where many sites will run of the same MVC application. I have a list of Sites stored in the HttpRuntime.Cache. Is it wrong to access the cache via a static method? Should I instead be passing this on view data? For example, is this wrong on the view: <%= SiteHelper.CurrentSite %> Where the code for SiteHelper is...

Uses for both static strong typed languages like Haskell and dynamic (strong) languages like Common LIsp

I was working with a Lisp dialect but also learning some Haskell as well. They share some similarities but the main difference in Common Lisp seems to be that you don't have to define a type for each function, argument, etc. whereas in Haskell you do. Also, Haskell is mostly a compiled language. Run the compiler to generate the execu...

Implementation in global functions, or in a class wrapped by global functions

I have to implement a set of 60 functions, according to the predefined signatures. They must be global functions, and not some class's member functions. When I implement them, I use a set of nicely done classes provided by 3rd party. My implementation of most functions is quite short, about 5-10 lines, and deals mostly with different ac...

Tool to help identify which parts of a common DLL are used by only one project? (.NET)

Our group has a "tools library" DLL that several of our internal projects (all C#) make use of. I've developed the intuition that a good chunk of the tools library is used only by one of the projects -- let's call that project "Project A". Are there any .NET tools that can examine the tools DLL and all the projects (maybe the project EXE...

Building iPhone Code using xcodebuild and running LLVM/Clang Static Analyzer

I followed the steps here but i'm unable to run static analyzer on my project: Finding memory leaks with the LLVM/Clang Static Analyzer When i try to run xcodebuild on my project (1. Open Terminal, 2. Go to Project Directly, 3. > xcodebuild), i get this error: === BUILDING NATIVE TARGET XProject OF PROJECT XProject WITH THE DEFAULT...

Storing Data In Memory: Session vs Cache vs Static

A bit of backstory: I am working on an web application that requires quite a bit of time to prep / crunch data before giving it to the user to edit / manipulate. The data request task ~ 15 / 20 secs to complete and a couple secs to process. Once there, the user can manipulate vaules on the fly. Any manipulation of values will require...

Share static singletons through EJB's

I'm trying to create a cache in a webservice. For this I've created a new Stateless Bean to provide this cache to other Stateless beans. This cache is simply a static ConcurrentMap where MyObject is a POJO. The problem is that it seems as there are different cache objects. One for the client beans, and another locally. -CacheService -Ca...

Accessing child variables from the super class without instanciation

I'm attempting to access member variables in a child class via the parent class without instantiation. This is one of my attempts but B::getStatic() fails with Access to undeclared static property. Is there another solution to this, possibly without static? class A { static public function getStatic() { return self::$myS...

How is Java's notion of static different from C#'s?

I am reading Josh Bloch's book Effective Java and he suggests using a builder design pattern when building objects that have large amounts of members. From what I can see it isn't the vanilla design pattern but looks like his variation. I rather like the look of it and was trying to use it in a C# web application that I am writting. This...

How can Derived class inherit a static function from Base class?

struct TimerEvent { event Event; timeval TimeOut; static void HandleTimer(int Fd, short Event, void *Arg); }; HandleTimer needs to be static since I'm passing it to C library (libevent). I want to inherit from this class. How can this be done? Thanks. ...

Difference between static class and singleton pattern?

What real (i.e. practical) difference exist between a static class and a singleton pattern? Both can be invoked without instantiation, both provide only with one "instance" and neither of them is threadsafe. Is there any other difference? ...

Does static variables in php persist across the requests?

Static variable gotcha in php I am from Java background and have switched to php for one project recently. I have found one unexpected behaviour in php. Value set to some static variable is not staying persistent across the requests. I am not sure if this is the expected bahaviour. Because in java , you can always persist ver...