12
votes
Should I expose an instance's state with methods?
It seems upon updates by the OP that I glommed onto the wrong part of the text and the CQS aspect of this is not terribly relevant to the real question. I'm going to leave the original answer since it ...
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 concurrently ...
4
votes
Should I expose an instance's state with methods?
Should you use methods over properties?
Properties are kind of methods already. But, practically, if you do this you will run into problems with serialisation libraries and the like (vue observables) ...
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 there any good and modern approaches, to have variables that feel global (no need to pass them around explicitly), yet are local to an instance?
As the experts in this community point out, the solution is obvious: use OOP, enclose the state in objects and live a happy life:
import {F} from './f';
...
// myLibrary/index.ts
export class ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
instance × 21java × 6
object-oriented × 6
object × 3
static × 3
design × 2
c++ × 2
javascript × 2
inheritance × 2
class-design × 2
class × 2
singleton × 2
garbage-collection × 2
design-patterns × 1
architecture × 1
database × 1
python × 1
c × 1
api × 1
api-design × 1
mvc × 1
terminology × 1
interfaces × 1
json × 1
logging × 1