-
-
Notifications
You must be signed in to change notification settings - Fork 27k
#677 add pattern Trampoline. #696
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
Conversation
Throttling test has failed. |
It is a known issue #643 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The project is missing from parent
pom.xml
- The module build fails with Checkstyle errors
trampoline/README.md
Outdated
it is possible to implement algorithms recursively in Java without blowing the stack | ||
and to interleave the execution of functions without hard coding them together or even using threads. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to explain the pattern shortly in Explanation
section? See https://github.com/iluwatar/java-design-patterns/wiki/02.-Pattern-template and some other patterns like http://java-design-patterns.com/patterns/decorator/ for examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i added section,
trampoline/README.md
Outdated
* [Trampolining: a practical guide for awesome Java Developers](https://medium.com/@johnmcclean/trampolining-a-practical-guide-for-awesome-java-developers-4b657d9c3076) | ||
* [Trampoline in java ](http://mindprod.com/jgloss/trampoline.html) | ||
* [cyclops-react](https://github.com/aol/cyclops-react) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Tutorials
section for examples. Pattern descriptions can be in Credits
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed it.
trampoline/pom.xml
Outdated
<version>1.16.18</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Lombok should be project level decision. We haven't used it elsewhere so please do not take it into use in one pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
the key enabling mechanism is the fact that Trampoline.more is a lazy operation. | ||
Trampoline in cyclops-react extends java.util.Supplier. Calling Trampoline.more we are basically creating | ||
a Supplier that defers the actual recursive call, and having defered the call we can move it outside of the recursive loop. | ||
This means we can define algorithms recursively in Java but execute them iteratively.*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refer to methods properly in Javadoc e.g. {@link package.class#member label}. What is cyclops-react?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cyclops-react is a library for additions java8 streams.
done.
Trampoline in cyclops-react extends java.util.Supplier. Calling Trampoline.more we are basically creating | ||
a Supplier that defers the actual recursive call, and having defered the call we can move it outside of the recursive loop. | ||
This means we can define algorithms recursively in Java but execute them iteratively. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please prefer <p> tag in Javadoc. See other patterns for examples. Please describe what the example does and how it implements the pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
public class TrampolineAppTest { | ||
|
||
@Test | ||
public void test()throws IOException{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use descriptive test method name? What does it test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Changed to testTrampolineWithFactorialFunction
@besok please comment when you've implemented the changes. |
Ok. I am going to do it on holidays(20-21.01) |
How can i add this modula to parent pom? |
@iluwatar , can you check my changes? |
Well done @besok 👍 Thanks for the new pattern! |
Pull request title
Pull request description