Questions tagged [instance]

In object-oriented programming an instance is an occurrence or a copy of an object, whether currently executing or not.

Instances of a class share the same set of attributes, yet will typically differ in what those attributes contain. For example, a class "Employee" would describe the attributes common to all instances of the Employee class. For the purposes of the task being solved Employee objects may be generally alike, but vary in such attributes as "name" and "salary".

Related tags:

5388 questions
18
votes
9 answers

Sql Azure - separate servers?

Let me preface this question by saying I'm neither a database nor Azure expert. It appears that MS charges by the size and number of Sql Azure dbases and not by the number of servers. Thus, cost-wise it seems feasible to put a single dbase on each…
Don
  • 531
  • 6
  • 13
18
votes
4 answers

In Ruby, inside a class method, is self the class or an instance?

I know that self is the instance inside of an instance method. So, then, is self the class inside of a class method? E.g., Will the following work in Rails? class Post < ActiveRecord::Base def self.cool_post self.find_by_name("cool") …
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
18
votes
1 answer

qApp versus QApplication.instance()

With PyQt5, both of these return the application object: app = QtWidgets.QApplication.instance() app = QtWidgets.qApp for i in app.arguments()[1:]: ... But why does print(QtWidgets.QApplication.instance() is QtWidgets.qApp) print False?
Sir Visto
  • 683
  • 1
  • 4
  • 9
18
votes
3 answers

Accessing typedef from the instance

As in stl containers, why can't we access a typedef inside the class from the class instance? Is there a particular insight into this? When value_type was a template parameter it could help making more general code if there wasn't the need to…
piotr
  • 5,657
  • 1
  • 35
  • 60
17
votes
2 answers

django signals, how to use "instance"

I am trying to create a system which enables user to upload a zipfile, and then extract it using post_save signal. class Project: .... file_zip=FileField(upload_to='projects/%Y/%m/%d') @receiver(post_save, sender=Project) def…
Umur Kontacı
  • 35,403
  • 8
  • 73
  • 96
17
votes
5 answers

Constructor overloading - best practice in Java

Constructors can be overloaded as any other method as well and I am aware of that fact. Due to a task I decided to use an abstract superclass with multiple constructors: Abstract Superclass: protected ListSortierer() { this( null, null…
L.Spillner
  • 1,772
  • 10
  • 19
17
votes
6 answers

Writing to a static variable in an instance method, why is this a bad practice?

I am a little confused here with this findbugs warning in eclipse. public class MyClass { public static String myString; } public class AnotherClass { public void doSomething() { MyClass.myString = "something"; } } This gives me…
Oscar Gomez
  • 18,436
  • 13
  • 85
  • 118
17
votes
13 answers

Trying to connect internally to Oracle, getting an idle instance?

So I have an Oracle instance, and I know it's running on this system, I've su'd to the oracle user, and I'm trying to connect using "/ as sysdba". However, when I do connect, it says the instance is idle. I know the database is up and opened,…
seanbseanbseanbseanb
17
votes
3 answers

Is an instance of a class automatically created when you first call a static method

I would like to know if you have a class with only static methods in it, does an actual instance of the class get created somewhere when you call 1st static method? This is somewhat confusing to understand in terms of memory management as you never…
AlexVPerl
  • 7,652
  • 8
  • 51
  • 83
17
votes
14 answers

Can a C++ Class Constructor Know Its Instance Name?

Is it possible to know the object instance name / variable name from within a class method? For example: #include using namespace std; class Foo { public: void Print(); }; void Foo::Print() { // what should be…
Adam Dempsey
  • 2,913
  • 5
  • 24
  • 26
17
votes
1 answer

Purpose of Instance Methods vs. Class Methods in Objective-C

I have checked out all these questions... Difference Class and Instance Methods Difference between class methods and instance methods? What is the difference between class and instance methods? ...and all they explain is how instance methods are…
pasawaya
  • 11,515
  • 7
  • 53
  • 92
16
votes
3 answers

Instance is an "object", but class is not a subclass of "object": how is this possible?

How is it possible to have an instance of a class which is an object, without the class being a subclass of object? here is an example: >>> class OldStyle(): pass >>> issubclass(OldStyle, object) False >>> old_style = OldStyle() >>>…
Eric O. Lebigot
  • 91,433
  • 48
  • 218
  • 260
16
votes
8 answers

Difference between reference and instance in javascript

Sometimes I hear people say "a reference to a object" and some say "a instance of a object" What is the difference?
James Fair
  • 598
  • 1
  • 7
  • 18
16
votes
4 answers

Is there no standard (Either a) monad instance?

I was under the impression that there was an instance for Either a somewhere, but I can't seem to find it. I have tried importing Control.Monad, Control.Monad.Instances and Data.Either as shown module Main where import Control.Monad import…
Boris
  • 5,094
  • 4
  • 45
  • 71
16
votes
3 answers

Create immutable object, instantiated without new

Can I create a class that instantiates with just the = operator, like the String class does? Or is that a feature specific to String class in Java?
matthew
  • 179
  • 4