3 ms·
IMO, “wrong question”, but thanks for asking. IMHO - “class” definitions are really just a data structure (abstractly, a possibly-nested hash) with associated
by RangerScience 2y ago
IMO, “wrong question”, but thanks for asking.
IMHO - “class” definitions are really just a data structure (abstractly, a possibly-nested hash) with associated functions, and that’s it.
This is extremely apparent in Perl, where that’s literally what a “class” is - a hash data structure “blessed” with a class name. JS is almost identical (a class is a hash where some of the values are functions), and “under the hood” both Ruby and Python are similar (although in very different ways - consider that the first arg in a member function in Python is the instance).
Database schema is (usually/mostly) just that structure without those functions; then you maybe use an ORM to provide them again.
So, IMO, on a theory and design level, both the database table and the data part of a class definition are “data structures” (note that you should include in considerations the relationships between data structures)
- jghn 2y agoTo take this a step further, IMO a big issue with how OOP is taught & practiced is that people approach it from the wrong direction. As classes provide both data and functionality, it's better to first model your data and then think about the functionality to provide on those data. But people tend to think about relationships & actions (i.e. functionality) first and model their data to that. The two approaches will tend to produce very different data structures. I'd agree with the sentiment from the OP that being data-first is ideal.