The static-methods tag has no wiki summary.
0
votes
1answer
102 views
JavaScript static methods retrieval
I have been thinking about it and wanted some feedback, recently I thought about doing it like this:
function foo(){
if ( !foo.prototype.statics ){
foo.prototype.statics = {
// ...
-1
votes
4answers
189 views
Immutable vs mutable object as returned parameter for class method [closed]
There is a class method (static method) in which I create and build some object. And for filling that object, I create it as mutable object.
My mutable object is a subclass of immutable object. So ...
3
votes
3answers
149 views
What is a static method compared to instance/class/private/public methods?
I'm learning programming in Objective-C and I can't understand what a static method is. I know what class/instance/private/public methods are. Can someone explain what it is using an example and ...
4
votes
1answer
300 views
How to implement syntax sugar in OO
The Problem
I regularly find myself writing the same code over and over again.
For example if I want a value from a nested array structure I end up writing something like this:
$config = ...
1
vote
3answers
352 views
OO PHP static keyword, should I use it?
I'm writing script for fb and I have 3 objects that I'll be using through all classes. I'm wondering if there is any advantage in using the static keyword except I don't have to create an instance ...
6
votes
3answers
191 views
“static” as a semantic clue about statelessness?
this might be a little philosophical but I hope someone can help me find a good way to think about this.
I've recently undertaken a refactoring of a medium sized project in Java to go back and add ...
2
votes
3answers
220 views
Syntactic sugar in PHP with static functions
The dilemma I'm facing is: should I use static classes for the components of an application just to get nicer looking API?
Example - the "normal" way:
// example component
class Cache{
abstract ...
-3
votes
2answers
316 views
Why don't inherited methods use child properties? (PHP)
I'm trying to get the code below to work in child classes. But it keeps failing because it is checking the basicDbClass rather than the child class.
For those complaining and voting my question down ...
4
votes
4answers
466 views
Could implicit static methods cause problems?
This is a purely hypothetical question.
Say I create a class method that contains no references to instance variables or other resources. For example (C#):
protected string FormatColumn(string ...
1
vote
4answers
226 views
Using static in PHP
I have a few functions in PHP that read data from functions in a class
readUsername(int userId){
$reader = getReader();
return $reader->getname(userId);
}
readUserAddress(){
$reader = ...
36
votes
6answers
2k views
How to deal with static utility classes when designing for testability
We are trying to design our system to be testable and in most parts developed using TDD. Currently we are trying to solve the following problem:
In various places it is necessary for us to use static ...
3
votes
3answers
3k views
Static class vs Singleton class in C# [duplicate]
Possible Duplicate:
What is the difference between all-static-methods and applying a singleton pattern?
I need to make a decision for a project I'm working of whether to use static or ...
10
votes
14answers
1k views
When do 'static functions' come into use?
OK, I've learned what a static function is, but I still don't see why they are more useful than private member functions. This might be kind of a newb-ish question here, but why not just replace all ...
2
votes
1answer
281 views
Is @staticmethod proliferation a code smell?
Consider a Python class with a number of @staticmethod methods and few instance methods. The static methods don't accept an instance of the defining class as parameters.
Do you think that all these ...
6
votes
3answers
2k views
Do private static methods in C# hurt anything?
I created a private validation method for a certain validation that happens multiple times in my class (I can't store the validated data for various reasons). Now, ReSharper suggests that the function ...