Questions tagged [static-classes]

In object oriented programming a static class is a class whose members must be accessed without an instance of the class. Its members must be created as static.

In object oriented programming a static class is a class whose members must be accessed without an instance of the class. Its members must be created as static.

289 questions
0
votes
1 answer

Javafx - should i make a static class for controlling my AI or an Object for each?

I am making a poker game (Texas Hold Em) and am wondering if I should be making a static class that controls all AI for simplicity or should I be aiming at making it in itself an instance so that each player could possibly use a different algorithm?…
0
votes
2 answers

Singleton vs Static Class for File Writing and a Mock-Data Base

I do recognize that this question has been asked many times before, but I can't get the answer I want out of it. And that question is, "Should I use a singleton or a class with all static members and methods?" I only ever need one instance for what…
Josiah Savoie
  • 135
  • 12
0
votes
1 answer

Getting a class name from iside a another classe's method

I would like to know if there is a way to access information when a method is called from inside a class. Example. Here I have a class, with a __classStatic() method, to generate arbitrary methods. class Caller { public function…
robue-a7119895
  • 816
  • 2
  • 11
  • 31
0
votes
2 answers

find a value in a nested categorized static class in C#

I need to find a value inside a structure (the first that came in my mind was a static class, but anything will do) that has to be a hierarchical structure like: public static class SheetGroups { public static class Coverage { public…
culebrin
  • 125
  • 1
  • 15
0
votes
2 answers

Best practice for object creation in unit tests?

For my unit tests I need a lot of specific, large (many fields) objects. I need multiple different instances for all my testclasses. As far as I know I have a few options and I was wondering what would be the best: extend the constructors of the…
Tom Jonckheere
  • 1,630
  • 3
  • 20
  • 37
0
votes
2 answers

Static private data member not initialized in static class?

Given the C# code below, I expected the private data member _userDataStorage to be initialized immediately. Instead I find that it is not being initialized at all. I put a breakpoint on the initialization statement and it is never hit. This means…
Robert Oschler
  • 14,153
  • 18
  • 94
  • 227
0
votes
2 answers

Odd Static Class Issue

Below is my very simple static class. Not sure what is wrong. I am using it in a non static class that has a correct "using" statement. Intellisense sees the class and its one method. I am getting the error The name 'SQLUserDataManager' does not …
bobber205
  • 12,948
  • 27
  • 74
  • 100
0
votes
1 answer

Check if a static class is declared (using reflection)

Trying to check if class K is a static class of A class A { private static class K { static final int MODE1 = 1; static final int MODE2 = 2; } } Class c = A.class; for( Class item: c.getDeclaredClasses() ) { if(…
ilomambo
  • 8,290
  • 12
  • 57
  • 106
0
votes
4 answers

Scope of static class constructor and static class fields

I have 2 Console Applications (Console1 and Console2) in one solution. Both applications reference a class library (CL). CL contains a static class (SC) which contains fields that are set per constructor. My question is if I call the static class…
Matt
  • 7,004
  • 11
  • 71
  • 117
0
votes
0 answers

Using a static class inside CakePHP application

Possible Duplicate: Instantiating a vendor class in class constructor I have a 3rd party vendor class called fancyVendor and I load it inside my controller with this: App::import('Vendor', 'fancyVendor', array('file' => 'fancyVendor.php')); class…
trante
  • 33,518
  • 47
  • 192
  • 272
0
votes
3 answers

Access static class member using the outer class

I have code like this I need to access the mysample variable of static class InnerClass in the getInnerS() method which is inside the the NestedClass. I tried accessing it by creating a new object for InnerClass but i am getting…
Prakash_se7en
  • 88
  • 2
  • 3
  • 16
0
votes
1 answer

Database model and extension method

In my ASP.NET web site I created new Entity Data Model and connected it with my MsSql database. Now I can use Model.Student class but that class don't have methods. I tried to add extension methods like public static class Functions{ public…
MrD
  • 2,423
  • 3
  • 33
  • 57
0
votes
1 answer

Calling a non-static method from within static Map Class in Hadoop

Using DistributedCache in Hadoop by Yavcular In the above link, it is described how to use DistributedCache in Hadoop in an easy to understand way. But the problem is, when I trt to compile the code, I get the following error: non-static method…
Ahmadov
  • 1,567
  • 5
  • 31
  • 48
0
votes
1 answer

Static class Object reference not set to an instance of an object

I have the next static class: public static class GlobalVar { public static string DatabaseName = "ProjectDatabase.mdf"; public static AdminClass Admin; public static string TruePath = AppDomain.CurrentDomain.BaseDirectory; public…
Novak
  • 2,760
  • 9
  • 42
  • 63
-1
votes
1 answer

Where are the inner static classes are stored in new Java versions?

Where are the inner static classes are stored in new Java versions? If static classes are stored in heap memory/ metaspace then how the below Singleton pattern implementation is thread safe? public class BillPughSingleton { private…