Skip to content

Solution #1 (take 1) - Use a result object that map all possibile paths/... #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

matteobaglini
Copy link
Contributor

...use cases as methods, something like Boolean object in Smalltalk. Since Java 1.7 doesn't have block (aka lambda) like Smalltalk (and many other languages) I chose to use AnonimousClasses but they seem to have many scope issues with local variable. Next shot I'll try to use Java 1.8 with the brand new lambda support.

…hs/use cases as methods, something like Boolean object in Smalltalk. Since Java 1.7 doesn't have block (aka lambda) like Smalltalk (and many other languages) I chose to use AnonimousClasses but they seem to have many scope issues with local variable.
@matteobaglini
Copy link
Contributor Author

This solution isn't obvious as the switch one, however, has two major advantages:

  • The use of the "PermissionAction" indirection decouple the callee from caller and "AskResult" is unaware of the context where it's used so it's more reusable.
  • The switch construct has the drawback that hard code the variation logic (aka procedural polimorfism), with the introduction of objects we open up to more powerful version of polimorfism and then objects composition in order to compose more complex high order logic without setting your hair on fire.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants