Skip to main content
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 ...
JimmyJames's user avatar
  • 31.1k
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 ...
DeadMG's user avatar
  • 36.9k
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) ...
Ewan's user avatar
  • 84.6k
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
  • 12.1k
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
  • 12.4k
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 ...
Blue Nebula's user avatar
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
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.9k

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