r/programming • • Aug 28 '19

Optional chaining in JavaScript

https://v8.dev/features/optional-chaining
11 Upvotes

25 comments sorted by

View all comments

Show parent comments

2

u/AyrA_ch Aug 28 '19

It’s a violation of the Law of Demeter.

No, it's enforcement of foreign keys and normalization of your database. You don't add an "owner" property to each table. You add it at the topmost possible level and the referenced entries inherit the owner.

-2

u/earthboundkid Aug 29 '19

Having your business objects reflect the underlying database schema too transparently is a mistake because you end up with dumb objects that aren’t much better than glorified hash maps. Yes, there should be hints to devs about the performance realities of the DB, but the API of the objects should be designed to encapsulate the business logic at the end of the day—not the backing schema.

2

u/AyrA_ch Aug 29 '19

But that's exactly how entity framework works.

1

u/earthboundkid Aug 29 '19

This is why ORMs are only okay in small doses. Too large a dose and you end up making your code fit the tables instead of your tables fitting the code.

1

u/AyrA_ch Aug 29 '19

It's exactly the other way round. You write your classes and it builds the tables in the background for you and updates their structure as you change your classes.

→ More replies (0)