Re:Why I hate all articles about design patterns (2016)
by crimsonalucard on Monday March 05, 2018 @04:27AM
(#16519820)
I know Haskell. We don't even need to address replacing exceptions with monads to show how and why OOP and patterns are in many many cases a bad solution.
Re:Why I hate all articles about design patterns (2016)
by smadge on Tuesday March 06, 2018 @01:23PM
(#16530781)
The point has nothing to do with functional vs oop, or exceptions versus monads. It has to do with using the features of your language of choices type system to prevent bugs. The thing going on here is putting validation logic in your type constructors so it's impossible to construct an invalid type without triggering a runtime "exception" or error.
Re:Why I hate all articles about design patterns (2016)
by crimsonalucard on Friday March 16, 2018 @11:08AM
(#16601169)
Ok I get your point. You can still have a function take in an address object rather than inserting into another object with a constructor.
You are correct in that building types leads to a more safe program but I was more addressing the flaw with objects rather then types.
For example I could have the only way to construct an email address be (in Haskell)
With the validation logic in the constructor. This is no more complicated than your solution.As an added benefit my type signatures are now also doubling as documentation.