static

Should I refactor static nested classes in Java into separate classes?

I have inherited code which contains static nested classes as: public class Foo { // Foo fields and functions // ... private static class SGroup { private static Map<Integer, SGroup> idMap = new HashMap<Integer, SGroup>(); public SGroup(int id, String type) { // ... } } } From reading SO (e.g. http://...

Does C# have an equivalent of Java static nested class?

I am converting Java into C# and have the following code (see discussion in Java Context about its use). One approach might be to create a separate file/class but is there a C# idom which preserves the intention in the Java code? public class Foo { // Foo fields and functions // ... private static class SGroup { ...

Scala: how to inherit a "static slot"?

Well, I'm learning Scala so this question may be too basic for most people. In Java I can have a static slot (function or variable) in a class, and then I will have that slot in inherited classes too. In Scala I don't have static slots, but I have companion objects. But I'm finding out that those objects are not part of the inherited c...

SqlConnection as a static singleton object

public class db { public static string connectionString = WebConfigurationManager.ConnectionStrings["connectString"].ConnectionString; public static SqlConnection OpenConnection() { SqlConnection connection = new SqlConnection(connectionString); connection.Open(); return connection; } }...

Passing Static arrays as parameters for Dynamic arrays in Delphi

Hi dudes, I have this array: const / var _Data : array [0..4] of array [0..3] of Double = ((0,0,0,0), (0,0,1,1), (1,0,1,0), (1,1,0,0), (1,1,1,1)); I wanna pass it as param value for this procedure: procedure NN.NetTraining(Data: TDoubleMatrix); Where: TDoubleArray = array of Double; TDoubleMatri...

Accessing value of a non static class in a static class

in ASP.NET C#., How can i set the variable values of a static class from the value present in a non static class .edx : I have a static class called staticA and a non static class called B which inhertits system.WEb.UI.Page. I have some values present in the class B ,which i want to set as the property value of the static class A so that...

Enable document footer

I tried to use Enable document footer function in IIS6 for my web sites after some tests i discovered that it works for static files only may i config it for pages like aspx or asp or maybe u have alternative solutions? ...

Why is MvcApplication.RegisterRoutes defined as static?

I know this could be silly, but would like gurus to clarify it for me... Why is this method defined as static .. public class MvcApplication : System.Web.HttpApplication { /* Why this method is declared as static? */ public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*path...

Objective-C/iPhone Memory Management Static Variables

I have a static method that creates an instance of the class and puts it in the static variable. I am wondering what the proper way of memory management is in this situation. You can't put it in the dealloc-method, because although it can access the static variable any instance method that is created that get's released will also relea...

Static Access to HashMap/Array?

Here's an example of a static method that is used in a web application. As you can see, the String[] allergensArr gets insantiated each time that this method is called. It's threadsafe since it's in a static method but it's an expensive call. What are some other ways that the allergensArr[] can be used so that it's not instantiat...

Python: static variable decorator

I'd like to create a decorator like below, but I can't seem to think of an implementation that works. I'm starting to think it's not possible, but thought I would ask you guys first. I realize there's various other ways to create static variables in Python, but I find those ways ugly. I'd really like to use the below syntax, if possible...

What is significance of static keyword in Java and in C++ ?

What is the importance of Static keyword in Java and in C++ and how it's functionality differ in both programming languages ? ...

Java: When to make methods static v. instance

I have a Gene class that keeps track of genes. Gene has a method for calculating the distance between two genes. Are there any reasons to make it static? Which is better? public static int geneDistance(Gene g0, Gene g1) or public int geneDistance(Gene other) Arguments for/against making it static? I understand what it means for a me...

Confused on const correctness with static array of pointers to const objects

I'm still not sure I totally get how this particular case should work out. So if I want to declare an array of NSStrings that won't change, is this correct? static NSString * const strings[] = {@"String 1", @"String 2", ...}; Is the static necessary? (what does it do?) Am I missing an extra const somewhere? There's just too many pl...

Threading with .NET and OpenCV?

...

PHP Using a variable when calling a static method

Hi, I have three classes that all have a static function called 'create'. I would like to call the appropriate function dynamically based on the output from a form, but am having a little trouble with the syntax. Is there anyway to perform this? $class = $_POST['class']; $class::create(); Any advice would be greatly appreciated. ...

MVC 1.0 DropDownList static data select not working

I'm new to MVC and C#. I'm trying to get a static list to work with a DropDownList control such that the selected value rendered is set by the current Model value from the DB. In the controller, I have: ViewData["GenderList"] = new SelectList(new[] { "Female", "Male", "Unknown" }, donor.Gender); In the view: Gender:<%=Html.DropDo...

Static inline methods?

Okay, Here is what I'm trying to do... Right now it is compiling but failing at linking... LNK2001 I want the methods static because there are no member variables, however I also want them inline for the speedups they provide. What is the best way to do this? Here is what I have in a nutshell: /* foo.h */ class foo { static vo...

Does static imply no state

I recently made a recommendation to one of my colleagues stating that on our current project (C#) "services should be stateless and therefore static". My colleague agreed and indicated that in our project the services are (and should be) indeed stateless. However my colleague disagreed that static implies no state and that stateless sh...

Static Classes in Servlet

I make static classes in servlet, these classes are controllers for web pages. Requests are redirected to controllers by controller urls that are in static HashMap that contains all controllers. Are there any posibilities that user/session realted stuff could get messsed up with other users sessions? I will of course save all session rel...