Re:Effective Programs: 10 Years of Clojure
by mopierotti on Tuesday October 31, 2017 @02:08PM
(#15595231)
I haven't watched the full video, but here are some things that a hypothetical Person class brings to the table that you might be missing:
1) A Person class can guarantee that a Person can not exist unless it is fully specified. E.g. you prevent Persons from being created that don't have a date of birth.
2) A Person class provides a syntactically nice place to put pieces of code that rely on the instance fields. E.g. a function like Person(...).computeAge(DateTime.now)
3) A Person class can be a nice place to put inter-field validations. E.g. Maybe you don't want to allow Persons to be constructed if their last name is the same as their first name
4) A Person class can bring clarity to function signatures that depend on it. Basically resolving the problems that Duck-typing introduces
1) A Person class can guarantee that a Person can not exist unless it is fully specified. E.g. you prevent Persons from being created that don't have a date of birth.
2) A Person class provides a syntactically nice place to put pieces of code that rely on the instance fields. E.g. a function like Person(...).computeAge(DateTime.now)
3) A Person class can be a nice place to put inter-field validations. E.g. Maybe you don't want to allow Persons to be constructed if their last name is the same as their first name
4) A Person class can bring clarity to function signatures that depend on it. Basically resolving the problems that Duck-typing introduces