We have our own custom ORM wrapper with classes like Contact
, Company
, etc., which have properties such as Name
, Address
, and so on. You "create" an instance of a class, which implicitly downloads the current record from the database:
// fetch a contact with ID myRecordID from connection myConnection
Contact myContact = Contact.Create(myRecordID, myConnection);
myContact.Birthday = Date.Now;
Here's the thing: for performance reasons (plus other considerations such as transactions), saving doesn't happen implicitly when setting a property. Instead, you have to call save()
:
myContact.save(); // great! the new birthday is in the database
This works great — except when you forget to call save()
. The compiler won't see an issue, but the above code doesn't do anything useful without saving.
I'm wondering whether the API can let the compiler know that, when properties have been set, the compiler should warn if save()
isn't called before the Contact
instance leaves scope.