All Questions
8 questions
5
votes
2
answers
415
views
Using static factory methods to prevent unwanted input
Many years ago, I posted a problem I had with some code and received a well written detailed answer that suggested the use of factory methods. I liked this approach, because I can provide a method ...
9
votes
4
answers
17k
views
Why would passing objects through static methods be advantageous?
Why would there be an advantage to use a static method and pass the reference to an object as a parameter rather than calling the method on an object?
To clarify what I mean, consider the following ...
16
votes
1
answer
9k
views
Are we abusing static methods?
A couple of months ago I started working in a new project, and when going through the code it stroke me the amount of static methods used. Not only utility methods as collectionToCsvString(Collection&...
9
votes
5
answers
17k
views
Does making a method static save memory on a class you'll have many instances of?
In response to Aaronaught's response to the question at:
Can't I just use all static methods?
Isn't less memory used for a static method? I am under the impression that each object instance carries ...
0
votes
3
answers
4k
views
Drawback of using static method [duplicate]
For methods that never access instance variable or static variable and they act just like a function (name-spaced) and they are deterministic base on only the input arguments , I want to ask, are ...
4
votes
2
answers
31k
views
Calling static method from instance of class
As a developer I am fan of static methods.
Recently I come across difference between OOP languages about this static methods.
All OOP language use static method to access any method without ...
38
votes
3
answers
75k
views
When to use a Singleton and when to use a static class [duplicate]
I've searched about this here and on StackOverflow and found some differences between the two.
But I'm still not sure in what cases one would prefer a Singleton, and in what cases one would choose to ...
9
votes
6
answers
2k
views
Static functions vs classes
Let's say that I want to build some utility functions to do some basic maths with the BigDecimals, for example I want to have a function that computes the average of a List<BigDecimal>.
What is ...