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
13
votes
3 answers

When do instance variables get initialized and values assigned?

When does the instance variable get initialized? Is it after the constructor block is done or before it? Consider this example: public abstract class Parent { public Parent(){ System.out.println("Parent Constructor"); init(); } public…
Akh
  • 5,961
  • 14
  • 53
  • 82
12
votes
1 answer

How to use FacesContext.getCurrentInstance(), it returns null

I've been struggling for the last couple of days with the login part of my web app. I've gotten to the point where I can succesfully authenticate a user using the JDBCRealm on tomcat(by reading users from a sql server database). Now I want to send…
Andrei Dvoynos
  • 1,126
  • 1
  • 10
  • 32
12
votes
3 answers

GAE Go - "This request caused a new process to be started for your application..."

I've encountered this problem for a second time now, and I'm wondering if there is any solution to this. I'm running an application on Google App Engine that relies on frequent communication with a website through HTTP JSON RPC. It appears that GAE…
ThePiachu
  • 8,695
  • 17
  • 65
  • 94
12
votes
2 answers

How do i test that an object is an instance of a particular class in D?

How do i test that an object is an instance of a particular class in D? Something akin to Javascript's instanceof keyword?
Gary Willoughby
  • 50,926
  • 41
  • 133
  • 199
12
votes
1 answer

How to make a type an instance of Eq

I have a data type called Praat. I want Praat to be an instance of Eq so that two Praats are equal if and only if mx are equal. How does one do this? -- data type data Praat t = Praat [k] [(k,k,k,k)] -- praat gives the maximum frequency Praat t…
Eddy Freeman
  • 3,207
  • 6
  • 35
  • 55
12
votes
3 answers

How to speed up python instance initialization for millions of objects?

I have defined a python class named Edge as follows: class Edge: def __init__(self): self.node1 = 0 self.node2 = 0 self.weight = 0 Now I have to create approximately 10^6 to 10^7 instances of Edge using: edges= [] for…
Jiadong
  • 1,822
  • 1
  • 17
  • 37
12
votes
7 answers

Check if object is a 'direct instance' of a class

I have two classes: class Bar extends Foo { // Foo isn't relevant constructor(value) { if (!(value instanceof Foo)) throw "InvalidArgumentException: (...)"; super(); this.value = value; } } class Baz extends Bar { …
Sacha
  • 819
  • 9
  • 27
12
votes
3 answers

How to intercept instance method calls?

I am looking for a way to intercept instance method calls in class MyWrapper below: class SomeClass1: def a1(self): self.internal_z() return "a1" def a2(self): return "a2" def internal_z(self): return…
Vikas Vikas
  • 121
  • 1
  • 4
12
votes
1 answer

Access to composer autoloaded files in laravel 5

Trying to use a non-Laravel package: https://packagist.org/packages/luceos/on-app Edited composer.json to require it and did the composer install, update, then dump-autoload -o. This package requires an initialization:…
arikin
  • 188
  • 11
12
votes
2 answers

Multiple Projects using single laravel instance

I am new to Laravel. As per my research on this framework I find it quite useful for my projects. However I am facing difficulty in customizing it to use a single instance of Laravel framework for multiple projects. I do not want to follow the multi…
kanchan
  • 339
  • 1
  • 3
  • 15
12
votes
2 answers

Where can I find the name servers of Google Compute Engine?

I have uploaded a website to my Compute Engine instance and I wanted to set the registrar to send the visitors to the server (Compute Engine). Where can I get the name servers of my instance/server over Compute Engine?
12
votes
3 answers

Can I change a Python bound method object's __str__() attribute?

I would like to change the __str__() attribute of one of my class's methods. (Note: Not to be confused with "trying to change the method __str__()".) I have a class, MyClass, which has a method 'some_method'. I can change the way MyClass displays…
JS.
  • 14,781
  • 13
  • 63
  • 75
12
votes
1 answer

php call class method from static method inside same class but non instantiated

php 5.3+ Sorry for the long question, but I want to learn this completely. I know I can't call a non-static same class method from inside a static method, without the class being instantiated as an object. class Person { private…
Steve Wasiura
  • 768
  • 1
  • 8
  • 19
11
votes
3 answers

Guidelines for when to use Static class over instance class?

Possible Duplicate: When to Use Static Classes in C# Can someone please provide guidelines , standard checkpoints on when to create static class and when to create instance class. Basically many a times I see while writing a code that the same…
Dhananjay
  • 3,673
  • 2
  • 22
  • 20
11
votes
3 answers

Add ruby class methods or instance methods dynamically

I am quite new to Ruby, so still learning. I was researching quite a bit about how to add methods dynamically, and I was successful to create instance methods, but not successful when creating class methods. This is how I generated instance…
purbon
  • 193
  • 1
  • 1
  • 7