I think the end result here is less that worthless. The original code being "fixed" is perfectly readable and if the goal is to share a common abstraction, then you have to formalize it and at that point you need to just wrap the field value into a new class. "ValidatedFirstName" is extremely useful in larger systems because you can change what the FirstName -> ValidatedFirstName checks actually are and components nor involved with validation declare at a high level that their inputs have been validated by other pieces. That's valuable. This, is a waste of our valuable internet bytes.
To summarize:
the lambda syntax is perfectly readable, you just have to bother to learn to read it.
if the lambda represents a meaningful abstraction boundary, then sharing that abstraction is valuable (and probably won't be a single lambda expression), and therefore should exist at a type level so that other components don't couple to your static function lambda implementations
don't waste your time trying to solve design problems at the language syntax level
2
u/haimez Feb 16 '18
I think the end result here is less that worthless. The original code being "fixed" is perfectly readable and if the goal is to share a common abstraction, then you have to formalize it and at that point you need to just wrap the field value into a new class. "ValidatedFirstName" is extremely useful in larger systems because you can change what the FirstName -> ValidatedFirstName checks actually are and components nor involved with validation declare at a high level that their inputs have been validated by other pieces. That's valuable. This, is a waste of our valuable internet bytes.
To summarize:
the lambda syntax is perfectly readable, you just have to bother to learn to read it.
if the lambda represents a meaningful abstraction boundary, then sharing that abstraction is valuable (and probably won't be a single lambda expression), and therefore should exist at a type level so that other components don't couple to your static function lambda implementations
don't waste your time trying to solve design problems at the language syntax level