static

how to add static methods using groovy mixin

hi, I want to use the mixin feature of groovy to import methods as "class(static) methods" instead of instance methods. When i use mixin even though i have a static method in my mixin class it gets converted into a instance method in the destination class.I want the imported method to be a class(static) method.Is there a good way to do...

PHP: Get instance of static class by string value

I'm working on a php web api that was handed to me with a lot of code that needs to be refactored. The ones that wrote the code wanted to include a static configuration class to an api resource and then get an instance of that class something like this: <?php $obj = "User"; $confObjectSuffix = "_conf"; $confObject = $obj.$confObjectSuff...

Why I do not see a static variable in a loop?

I have a static method which sets a variable: static String[] playersNames; public static void setParameters(String[] players) { playersNames = players; } Then I have a static block: static { JRadioButton option; ButtonGroup group = new ButtonGroup(); // Wright a short explanation of what the user should do. partnerSe...

Static classes in PHP via abstract keyword?

According to the PHP manual, a class like this: abstract class Example {} cannot be instantiated. If I need a class without instance, e.g. for a registry pattern: class Registry {} // and later: echo Registry::$someValue; would it be considered good style to simply declare the class as abstract? If not, what are the advantages of h...

Access current instance of Page from a static class

Basic question - is it possible to access the current Page from a static class in ASP.NET? I am thinking no, as google turns up no results. ...

Getting rid of "static" references in C#

Hello. I've recently begun learning C# but have encountered an annoying problem. Every variable I want available to all functions in my program I have to put a "static" in front of and also every function. What I'd like to know is how to avoid this, if possible? Also, small side question: creating public variables inside functions? Thi...

Mixing Static Strings with Views Arguments

Hi. Can anyone tell me if it is possible to mix views arguments with static strings? For example in the path section of a view feed display I need: /mypath/%.xml with the ".xml" part being the static string. Thanks in advance. ...

Where the Static variable stores ( Data segment or Heap or BSS) ?

Some people are saying " static variable store its value in HEAP ", and others saying " static variable store store its value in DATA segment". I am totally confused with these conflict answers. Where exactly static variable stores?. I am expecting an answer with standard reference ( text books, or good author tutorial). Static variabl...

Why doesn't Visual Studio show an exception message when my exception occurs in a static constructor?

I'm running this C# code in Visual Studio in debug mode: public class MyHandlerFactory : IHttpHandlerFactory { private static Dictionary<string, bool> myDictionary = new Dictionary<string, bool>(); static MyHandlerFactory() { myDictionary.Add("someKey",true); myDictionary.Add("someKey",true); // fails due to duplicate key ...

singleton pattern in java- lazy Intialization

public static MySingleton getInstance() { if (_instance==null) { synchronized (MySingleton.class) { _instance = new MySingleton(); } } return _instance; } 1.is there a flaw with the above implementation of the getInstance method? 2.What is the difference between the two implementations.? public static synchronized MyS...

A function's static and dynamic parent

I'm reading Thinking in C++ (vol. 2): Whenever a function is called, information about that function is pushed onto the runtime stack in an activation record instance (ARI), also called a stack frame. A typical stack frame contains (1) the address of the calling function (so execution can return to it), (2) a pointer to...

Using Static methods or none static methods in Dao Class ?

Hi I generate Dao classes for some DB operations in this manner making methods of Dao class as static or none static is better? Using sample dao class below ,İf more than one client got to use the AddSampleItem method in same time?how this may result? public class SampleDao { static DataAcessor dataAcessor public static void ...

IOC - Should util classes with static helper methods be wired up with IOC?

Hi, Just trying to still get my head around IOC principles. Q1: Static Methods - Should util classes with static helper methods be wired up with IOC? For example if I have a HttpUtils class with a number of static methods, should I be trying to pass it to other business logic classes via IOC? Follow on questions for this might be: ...

Static variables in C and C++

Is there any difference between a variable declared as static outside any function between C and C++. I read that static means file scope and the variables will not be accessible outside the file. I also read that in C, global variables are static . So does that mean that global variables in C can not be accessed in another file? ...

Shared(Static) classes with events in C#

Here is an example of what i would do in vb: Public Class Class1 Public Shared WithEvents Something As New EventClass Public Shared Sub DoStuff() Handles Something.Test End Sub End Class Public Class EventClass Public Event Test() End Class Now how do i do this in c#. I know there is not handles clause in c# so i n...

Can't seem to get .Union to work (merging 2 array's together, exclude duplicates)

I want to combine two array's, excluding duplicates. I am using a custom class: public class ArcContact : IEquatable<ArcContact> { public String Text; public Boolean Equals(ArcContact other) { if (Object.ReferenceEquals(other, null)) return false; if (Object.ReferenceEquals(this, other)) return true; ...

Why static fields are not initialized in time?

Somebody tell me: class MyClass { private static MyClass myClass = new MyClass(); private static final Object obj = new Object(); public MyClass() { System.out.println(obj); // will print null once } } I wonder, isn't this a bug? Why static objects are not initialized before the constructor runs? --update I'd just copied...

Problem using delegates, static, and dependencyproperties

I'm trying to animate a private variable named radius, which works. However while its changing I'm trying to execute a function which is getting to be quite of a problem. the code i have is below, it wont run because it has the following error An object reference is required for the non-static field, method, or property 'AppPart.SetChil...

Is it safe to lock a static variable in a non-static class?

I've got a class that manages a shared resource. Now, since access to the resource depends on many parameters, this class is instantiated and disposed several times during the normal execution of the program. The shared resource does not support concurrency, so some kind of locking is needed. The first thing that came into my mind is ha...

How can a static class be resolved by the Unity Framework?

I wold like the unity framework to resolve a static class "MyStaticObject" specified in my config file. As my class is static, I am getting an error "The type StaticObject does not have an accessible constructor." My config file looks as below: <unity> <typeAliases> <typeAlias alias="singleton" type="Microsoft.Practices.Uni...