The tag has no wiki summary.

learn more… | top users | synonyms

13
votes
5answers
6k views

What is the difference between all-static-methods and applying a singleton pattern?

I am making a database to store information about the users of my website (I am using stuts2 and hence Java EE technology). For the database I'll be making a DBManager. Should I apply singleton ...
39
votes
8answers
18k views

Is static universally “evil” for unit testing and if so why does resharper recommend it?

I have found that there are only 3 ways to unit test (mock/stub) dependencies that are static in C#.NET: Moles TypeMock JustMock Given that two of these are not free and one has not hit release ...
2
votes
2answers
305 views

Static or non-static?

For example I have these two classes: First public class Example { public Example() { } public int ReturnSomething { return 1; } } Second public class Example ...
35
votes
9answers
11k views

Can't I just use all static methods?

What's the difference between the two UpdateSubject methods below? I felt using static methods is better if you just want to operate on the entities. In which situations should I go with non-static ...
43
votes
6answers
6k 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 ...
2
votes
3answers
2k 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 ...
1
vote
2answers
253 views

Is this a candidate for Singleton?

I have an external thermometer connected via USB that is controlled by my SW. Different parts of my system will use it but never at the same time (all in one thread). However, it is a single device ...
1
vote
3answers
286 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 = ...
0
votes
1answer
190 views

Why overriding a static method does not result in polymorphism in java

Many say that we can not override a static methods. But we can override a static method. The question is, when we override a static method why it does not result in polymorphism ?
6
votes
3answers
4k 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 ...