3 ms·
An idiomatic Java/C++ OO approach is to have an interface to the datastore that eliminates the need for the NULL. That way you don't need to know the internal d
by robotresearcher 13y ago
An idiomatic Java/C++ OO approach is to have an interface to the datastore that eliminates the need for the NULL. That way you don't need to know the internal details of the datastore object.
datastore.ChangePhone( personId, number );
could return a bool to indicate success/failure or throw a "personId not found" exception according to taste.
This is normal Java style and is in line with the article's recommended "tell-don't-get" approach.
Requires boilerplate inside datastore object, but hey, that's not exactly news for OO.
- ajanuary 13y agoOO doesn't mean boilerplate. Just because there's a correlation in languages like C++ and Java doesn't mean there's causation. Most of their boilerplate derive from the type system.