3 ms·
I think I disagree with most of the arguments for this, and I think the author's example of his own "something like DAO" is worse organization. I haven't used "
by Psilidae 9y ago
I think I disagree with most of the arguments for this, and I think the author's example of his own "something like DAO" is worse organization. I haven't used "DAO" but from what I understood reading this, it's my preferred pattern of doing database access in which objects are just data, and any database interaction would either return a data object, or take one as a parameter.
From my personal experience, I've found that trying to write database interaction methods on an object seemed to result in (subjectively) messier and harder to maintain code, compared to using functions that take or return objects. To achieve Encapsulation, I'd merge this into functions `static void update(Book b)` or `static Book get()` within the `Book` class.
Though, this preference comes from having been corrupted by functional principles and a strong preference for immutable data objects.