the `static` keyword, in programming languages, is used to define a function/method or field/property as bound to the context of a type/class, but not to any specific instance. Unlike constants, static properties can usually be changed at runtime.

learn more… | top users | synonyms

1
vote
3answers
47 views

How to overcome static referencing errors in Java/basic programming?

Someone posted a question on http://math.stackexchange.com earlier because their program to tranpose a matrix wasn't working. I copied the code they posted (which was just the transpose method) and ...
1
vote
1answer
65 views

Using static methods? [closed]

I am working on a ASP.NET web application and there was recently a need to dynamically generate columns. I created a static class ColumnBuilder.cs, which takes in an entity and returns an appropriate ...
0
votes
1answer
71 views

Could my object use static methods? Anything I need to do to make the code better?

With the Zend coding convention in the back of my mind, I have set this up. It lets you communicate with the API of the vendor TargetSMS. They allow you to bill customers trough SMS. For now I've ...
0
votes
1answer
123 views

Using UnitOfWork/Repository pattern in static class/methods

I know using a UnitOfWork/Repository pattern in a normal class should work fine without any issues but how about using them in a static class/methods (I mean using a private static IUnitOfWork ...
1
vote
1answer
91 views

A decent use-case for static property

I'm currently writing a REST-tool that connects to a third-party server (duh). They offer a fairly large (if not too large) API in a single wsdl file, as well as separate wsdl's for each specific part ...
1
vote
1answer
146 views

Java reflection and static classes

I try to intercept some OpenGL calls for testing my rendering classes. Reflection is used for replacing the OpenGL backend. I feel this class is badly written and I need advices for refactoring it. ...
6
votes
2answers
169 views

Handle static objects using custom adapter

I have read some articles discussing about why static is bad, some of them refering static as not-testable, non-mockable, has state (non-stateless) and everything else. However I have encountered ...
3
votes
1answer
109 views

Static variable in method vs private class property

I have a class with a method that will be called multiple times over an object's lifetime to perform some processing steps. This method operates on a mixture of immutable (does not change over the ...
4
votes
1answer
192 views

How to make static methods testable?

I am creating an application which will be testable(unit + integration). In this application I have a FileHelper static class, public static class FileHelper { public static void ...
3
votes
4answers
281 views

Is static method calls to a server a Java bad code smell?

I'm developing an Android app that performs several requests to a server using the AndroidAsynchronousHttpClient. One of these requests (as an example) is responsible to send the username and ...
0
votes
2answers
143 views

PHP my way of threating static classes

A few days ago I've faced an annoying problem. Let's imagine we have 3 classes: Base, System, Handler. The classes Systen and Handler both inherit from the class Base. I want to access those classes ...
1
vote
1answer
51 views

Using static for class default properties

I have made a class for generating html form elements: class input { public $tag = 'input', $type = 'text', $customClass, $name; public function __construct(array $cfg){ if ( ...
2
votes
1answer
93 views

PHP: multilingual Time::since() static class

I didn't make the math myself since I'm an idiot. I did however try to make it more versatile and usable for my multilingual page, which involves making it simple to use for advanced plural forms such ...
4
votes
4answers
160 views

Configuring toString via a public static variable

Sometimes I need toString() to be quite verbose, normally I don't. It can't be nicely solved by using other methods as toString() is what gets shown in debugger (and also in the logs unless I call ...
2
votes
2answers
380 views

What's wrong with static utility classes, versus beans?

My inclination is to make these methods static: package net.bounceme.dur.usenet.driver; import java.util.List; import java.util.logging.Logger; import javax.mail.Folder; import javax.mail.Message; ...
4
votes
3answers
287 views

`Static inheritance` pattern

I have an abstract class Entity in my code, which requires a reference to an instance of EntityData to operate. (EntityData provides basic information about the type of the entity). In the design of ...
6
votes
3answers
612 views

Static methods or singleton?

I have class that handles HTTP requests: public final class RestHttpClient { /*there is no fields*/ /** * @param mhttp - HTTP request that need to send * @return HttpResponse, ...
8
votes
3answers
1k views

Unit testing legacy code with static classes

I am adding new functionality into a legacy application. For my new classes I have introduced Unit Testing. I still need to work with the existing code. One of the problems I face is that a lot of ...
7
votes
3answers
1k views

What is a good naming convention for static class variables?

Member variables of objects are often prefixed m_ (m_bIsInitialized, m_wpszName, and so on.) What about static variables that belong to a class? I have also treated them like member variables, but is ...
2
votes
1answer
158 views

Static variable Current in Application

I was finding myself frequently calling getApplication() and casting it as MyApplication so that I could call a method in MyApplication. I decided to declare the static variable Current in ...
2
votes
1answer
152 views

Component functions - static vs. OO?

I'm writing a small PHP framework to help me develop Web applications. The framework is split into numerous components, each of which are automatically loaded according to the configuration settings. ...
2
votes
1answer
288 views

How can I improve this code without using static or singleton?

I used to use static or singleton for my DAL class. However, I read some articles saying that singleton is evil and should be avoided. Therefore I try to rewrite my code like this: public class ...
1
vote
0answers
175 views

Getting and setting a static variable

[Bindable] public class ProductsCache { private static var _products:ArrayCollection; public function get products():ArrayCollection{ return _products; } public function set ...
3
votes
3answers
620 views

Static class member destruction in C++

I have a basic cache set up. Whenever a user requests a bitmap, it fetches or loads it from disk if it isn't already loaded, significantly reducing load times. Currently, the design explicitly tells ...
1
vote
2answers
453 views

Staticton (Single static classes) in PHP [closed]

I know singletons are held in poor regard, but as I am writing my web app I feel like some completely static classes would be helpful. Of course, not much should be static, but what about things ...