Does anyone else think instance variables are problematic in database-backed applications?
Posted
by Ben Aston
on Stack Overflow
See other posts from Stack Overflow
or by Ben Aston
Published on 2010-05-31T13:00:18Z
Indexed on
2010/05/31
13:03 UTC
Read the original article
Hit count: 203
imperative-programming
|state-management
It occurs to me that state control in languages like C# is not well supported.
By this, I mean, it is left upto the programmer to manage the state of in-memory objects. A common use-case is that instance variables in the domain-model are copies of information residing in persistent storage (i.e. the database). Clearly this violates the single point of authority principle, and "synchronisation" has to be managed by the developer.
I envisage a system where instead of instance variables, we have simple public access/mutator methods marked with attributes that link them to the database, and where reads and writes are mediated by a framework that decides whether to hit the database. Does such a system exist?
Am I completely missing the point, or is there some truth to this idea?
© Stack Overflow or respective owner