4 ms·
It sounds like one issue is the conflation of Object and Data Structure. Book, in the presented example, has no behaviour so it is a DataStructure, making it a
by ncphillips 9y ago
It sounds like one issue is the conflation of Object and Data Structure.
Book, in the presented example, has no behaviour so it is a DataStructure, making it an object introduces needless overhead.
Also, I believe DAOs are intended to be used in more complex cases. For example, I may have a BookSeries class in my database, and I may want it’s instances to have a numberOfBooks property. NumberOfBooks would be a computed value, and it would be the job of the DAO to populate that field when retrieving the BookSeries.
This could go even further, where a class exist that does not map to the database table at all.
- wbkang 9y ago> It sounds like one issue is the conflation of Object and Data Structure. Do you mind expanding on this a little bit? I am very confused. A "data structure" is an implementation of an abstract data type (https://en.wikipedia.org/wiki/Data_structure https://en.wikipedia.org/wiki/Data_structure). A "class" is also an implementation of abstract data type (from this book https://www.amazon.ca/Object-Oriented-Software-Construction-Book-CD-ROM/dp/0136291554 https://www.amazon.ca/Object-Oriented-Software-Construction-... page 165). I am not sure how you can have a data structure Book without any operations. Even if it were a C struct, accessing a field would consist an operation around that data structure.