6 ms·
Really, what good reason is there to have data and behavior bound to the same object? Caches which require specific invalidation logic. A good mental model is
by mathgladiator 3y ago
Really, what good reason is there to have data and behavior bound to the same object?
Caches which require specific invalidation logic.
A good mental model is the query language for a database. The language provides a frontdoor for all the state, so you can't just poke around and mutate things.
- dimal 3y agoEh. I guess I don't see how `cache.invalidate()` is a drastic improvement over `invalidate(cache)`. And my experience with ORMs has also not been pleasant, although it's been a few years since I've used one. They seem very convenient for 80-90% of use cases, and a nightmare for the rest. And you don't know at what point your query will pass that invisible line into the nightmare zone. You start with something simple and it's very convenient, then as things change and get more complicated, the generated queries become more and more unperformant and confusing.
- mathgladiator 3y agoOnly if you understand the details of when the cache needs to be invalidated. I'm not sure where ORMs entered the picture, but my point is that the database uses the query engine to guard internal caches which are private via the process boundary. OOP is a technique which shouldn't prescribed for everything. I will say Javascript shouldn't have have classes, but I hope to never need to use JS much beyond glue.