CloudCoders / Design-Patterns

Project for learning and discuss about design patterns
16 stars 1 forks source link

Maybe/Option monad implementation example #27

Closed Cotel closed 7 years ago

Cotel commented 7 years ago

This resolve #26

While I was making the main example, @Nhemesy proposed me to use nullables and a great discussion appeared. Maybe monad offer us a really safe way to operate with variables but it can be confusing and too big. On the other hand, Kotlin nullables increase the safety of the code and they are way lesser code but at the end they can be null too.

Take a look at Main.kt and let's discuss which way to operate is better.

tonilopezmr commented 7 years ago

@Cotel this needs test

tonilopezmr commented 7 years ago

Also you can see the explanation of Option by Raul Raja

https://www.youtube.com/watch?v=cnOA7HdNUR4&index=2&list=PLKxa4AIfm4pUaVhRKxYErhAvjU9xqwZOb

Cotel commented 7 years ago

I would be very pleased if you all understood this Monad. Real Magic is happening here folks!

I recommend you to see the evolution of the code (there are only 2 commits) because last refactor can be scary but it's not, believe me 😉

tonilopezmr commented 7 years ago

I want to have a look tomorrow! We should start with basic functions!