Questions tagged [instance]

An instance is a particular occurrence of an object during the time when a computer program is running.

Filter by
Sorted by
Tagged with
2
votes
3answers
212 views

Are Instanced APIs a Problem in a C Interface?

So an Instanced API is one that behaves like an object. So for example: foo* GetInstancedAPI(); void MemFuncSetter(foo* fooThis, const int arg); int MemFuncGetter(const foo* fooThis) const; This is ...
0
votes
1answer
69 views

Identifying the use case for instantiation only through existing instances

I was in my CS class when my instructor presented me the following classes: public class UninstantiableTest { private static Uninstantiable uninstantiable; public static void ...
0
votes
2answers
446 views

Does anonymous object instantiation have advantages over static object creation in this specific case?

In a Java program which I did not made and cannot change, only write extensions for it, the design forces me to create an object which will never be garbage collected. I tested and I can do it through ...
-1
votes
4answers
2k views

Why do we need instance variable in object oriented programming?

I've been teaching myself Object Oriented Programming(Ruby) for a while. However, I still don't quite understand some of its core principles, specifically, instance variable. Could somebody please ...
1
vote
1answer
48 views

How to avoid fetching additional informations when instantiating objects

I'm creating an HTML5 game using javascript and have got some problems during the first instantiation of the objects of the scene. Scenario Self-written 2d game engine that supports multiple ...
-1
votes
1answer
139 views

How to force user to create new instance of object

I have library with asynchronous thread and application who use them. Application can pass object to library of type provide by library interface. If application does not create new instance of object ...
5
votes
1answer
5k views

Log4j logger per class vs logger per application

I am stuck at understanding a concept related to Logger creation, especially in the context of Java EE. In my experience, I nearly always used one logger per application, with few cases when I needed ...
0
votes
0answers
47 views

What happens to super handler with instance variables

What will happen if I extend a class A to a controller B, when A has instance variables (private, protected)? I have a main controller MY_Controller(handler) which has several methods: can_modify (...
2
votes
2answers
621 views

Python OO problem

I started learning Python yesterday and I ran into a problem. I like to hear some thoughts on it. As an exercise, I decided to build a chatserver. As part of the exercise, I wanted to write some ...
14
votes
4answers
4k views

Singleton or instantiate everytime I use? [duplicate]

I use a class that just extracts data from one known object, and distributes it to other known objects. No persistent configuration or such is needed in that class instance. How should I decide ...
14
votes
4answers
194k views

What are the differences between class variables and instance variables in Java? [closed]

I'm very new to Java and want to understand the difference between class variables and instance variables. For example: class Bicycle { static int cadence = 0; int speed = 0; int gear ...
1
vote
2answers
399 views

Objects or primitives as arguments

I have come across the term "garbage disposal" and now I'm worried about using up too much memory. Apparently (correct me if I'm wrong) every time an object is created, memory is reserved for it, and ...
1
vote
5answers
686 views

Understanding basics of object declaration in Java

Is there a case when an object is declared without a call to the constructor? as in, for example: ArrayList<Integer> grades; Or is it always the case that ArrayList<Integer> grades (as ...
1
vote
2answers
1k views

Instantiating objects in Java [closed]

I'm learning now Java from scratch and when I started to learn about instantiating objects, I don't understand - in which cases do I need to instantiate objects? For example I'm studying from TutsPlus ...
3
votes
4answers
551 views

Why are inheritance and interfaces restricted to instance members?

Disclaimer: I think the rules are almost the same in most OO languages, but since I'm most familiar with C# I'll be relating to this specific language. I think that the use of attributes and ...
2
votes
2answers
940 views

observer class as instance

Sometimes I read in observer-pattern descriptions, to make the constructor of a observer base class protected so the class will be abstract. but by making the constructor public (if even one is ...
18
votes
4answers
9k views

Make methods that do not depend on instance fields, static?

Recently I started programming in Groovy for a integration testing framework, for a Java project. I use Intellij IDEA with Groovy plug-in and I am surprised to see as a warning for all the methods ...