11
votes
Accepted
Why do we need instance variable in object oriented programming?
Instance variables are variables declare inside a class but outside any methods.
They can be accessed by all dynamic method of a class.
As opossed to a class variable which occurs only one for all ...
7
votes
Are Instanced APIs a Problem in a C Interface?
Is there a way minimize the lookup cost?
Yes- don't use a lookup. Instanced APIs are the way to go - non-instanced ones suffer from terrible problems like not having separate instances be ...
5
votes
Accepted
How to force user to create new instance of object
Usually you don't.
Think about how you can improve your interface to make this a non-issue. Depending on the given context, it might be sensible to treat objects as immutable, or copy them. Maybe you ...
4
votes
Identifying the use case for instantiation only through existing instances
What this pattern is doing is using access modifiers on constructors to limit construction to factory methods that have a hard coupling to other classes that are using setter injection. Why it's doing ...
3
votes
Why do we need instance variable in object oriented programming?
There are several different purposes of classes in OOP, but one of the most common is to act as a blueprint for creating objects. An instance variable is part of the blueprint for creating an object. ...
3
votes
Accepted
If an object x is an instance of a type T, then what is a type T for a concept C?
If you have classes A and B, and B is a derived class of A, that is a noun property. B has a fundamental relationship to A which the very definition of B must explicitly claim.
Concepts don't work ...
3
votes
If an object x is an instance of a type T, then what is a type T for a concept C?
A concept is a predicate. I'd use the term satisfies, as in
A type T satisfies the concept C when...
Many concepts specify requirements on the interface of a type. Taking a phrase from languages ...
2
votes
Are Instanced APIs a Problem in a C Interface?
I see no practical difference between the example you've given.
In the first case you've returned a pointer to an object. In the second, you've returned an index of that object in an array.
C ...
2
votes
Why do we need instance variable in object oriented programming?
In an object oriented language, you have objects. Often many objects. And these objects have state, each one of them has its own state, different from any other object's state.
Problem: How would ...
2
votes
Are Instanced APIs a Problem in a C Interface?
Callbacks are handled the same way every callback should be handled in C, a function pointer and a void* userdate/context pointer. The function pointer takes the parameters it needs and the context ...
1
vote
Does anonymous object instantiation have advantages over static object creation in this specific case?
So for an object that is never garbage collected by design, does anonymous object instantiation offer advantages over a static object creation?
I believe you are referring to the following as "static ...
1
vote
Why are inheritance and interfaces restricted to instance members?
The conceptual reason interfaces can't declare "abstract static members" is that the purpose of an interface is to specify what can be done with an object, not with a type. For example, the .NET ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
instance × 19java × 6
object-oriented × 5
object × 3
static × 3
design × 2
c++ × 2
inheritance × 2
class-design × 2
class × 2
garbage-collection × 2
architecture × 1
javascript × 1
database × 1
python × 1
c × 1
api × 1
api-design × 1
mvc × 1
terminology × 1
interfaces × 1
json × 1
logging × 1
use-case × 1
java-ee × 1