Skip to main content
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 ...
Tulains Córdova's user avatar
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 ...
DeadMG's user avatar
  • 36.9k
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 ...
Eiko's user avatar
  • 785
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 ...
candied_orange's user avatar
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. ...
Trixie Wolf's user avatar
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 ...
Nicol Bolas's user avatar
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 ...
Caleth's user avatar
  • 11.6k
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 ...
Jerry Coffin's user avatar
  • 44.7k
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 ...
gnasher729's user avatar
  • 47.5k
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 ...
ratchet freak's user avatar
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 ...
Erik Eidt's user avatar
  • 34.4k
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 ...
Sophie Swett's user avatar
  • 1,359

Only top scored, non community-wiki answers of a minimum length are eligible