in object-oriented programming, access from a static (class) context, as opposed to one from a particular object instance context

learn more… | top users | synonyms

1
vote
1answer
215 views

Storing session in a static variable?

I'm currently checking a older piece of C# code used to maintain a login session. public static ZRWebserviceSession CurrentSession { get { return _currSession; } set { _currSession = value; } } ...
1
vote
2answers
1k views

Best practice for creating a 'global' config class used by numerous components

I have a large project with a driver part and about 5 libraries doing various associated tasks. Many of the libraries require access to 'global' configuration data which is read from a database at ...
0
votes
1answer
101 views

How to 'convert' a Static Access style project to IoC/DI style?

Are there any best approaches for refactoring a programming project that has previously been written with the static reference anti-pattern (the majority of classes refer at some point to a static ...
4
votes
2answers
409 views

Is there a name for this design pattern? [closed]

I don't like singletons, but I have to compromise now (but only as temporary measure). However I don't want to go completely singleton. I'd rather want to use this pattern: interface ...
0
votes
1answer
191 views

In memory collection vs database vs individual classes for infrequently changed objects

I have a ASP.NET application which puts the users through a series of forms in a wizard like fashion and has them fill out fields on the form. In code, these forms and fields are represented as "Step" ...
2
votes
1answer
367 views

Why does this static field always get initialized over-eagerly?

I am looking at this excellent article from Jon Skeet. While executing the demo code, Jon Skeet says that we can expect three different kinds of behaviours. To quote that article: The runtime ...
2
votes
3answers
4k views

Static DataTable or DataSet in a class - bad idea?

I have several instances of a class. Each instance stores data in a common database. So, I thought "I'll make the DataTable table field static, that way every instance can just add/modify rows to its ...
1
vote
1answer
583 views

Static objects and concurrency in a web application

I'm developing small Java Web Applications on Tomcat server and I'm using MySQL as my database. Up until now I was using a connection singleton for accessing the database but I found out that this ...
21
votes
6answers
7k views

Why the static data members have to be defined outside the class separately in C++ (unlike Java)?

class A { static int foo () {} // ok static int x; // <--- needed to be defined separately in .cpp file }; I don't see a need of having A::x defined separately in a .cpp file (or same file ...
1
vote
1answer
387 views

Drawback of implementing DDD service as static class?

Can Services in a domain-driven design be implemented as C# static class? What are the drawbacks of this choice? Can it be implemented as a non-singleton non-static class?
3
votes
3answers
7k 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 ...
12
votes
1answer
698 views

Why is there no facility to overload static properties in PHP?

Intro PHP allows you to overload method calls and property accesses by declaring magic methods in classes. This enables code such as: class Foo { public function __get($name) { return 42; } } ...
1
vote
4answers
1k views

About shared (static) Members and its behavior

I just realized that I can access shared members from instances of classes (probably this is not correct, but compile and run), and also learn/discover that, I can modify shared members, then create a ...
4
votes
3answers
2k views

Why use sealed instead of static on a class?

Our system has several utility classes. Some people on our team use (A) a class with all-static methods and a private constructor. Others use (B) a class with all-static methods (these the juniors). ...
25
votes
3answers
975 views

Are static classes with static methods considered SOLID?

SOLID includes the Liskov substitution princicple which has the notion that “objects in a program should be replaceable with instances of their subtypes without altering the correctness of that ...
5
votes
1answer
361 views

Scoping recommendations while developing in C

While developing a library using C, what are your recommendations about variable and function scoping? In C++, OOP and namespaces made the whole thing a lot easier. But how to do that with plain C? ...
1
vote
6answers
2k views

Static classes and/or singletons — How many does it take to become a code smell? [closed]

In my projects I use quite a lot of static classes. These are usually classes that naturally seem to fit into a single-instance type of thing. Many times I use static classes and recently I've started ...
10
votes
2answers
2k views

Static is bad, but what about the Factory pattern?

I'm on a TDD project, so I try to stick as much as possible to the good pratices involved with that kind of development. One of them is avoiding as much as possible static and global. I'm facing this ...