Skip to content

#677 add pattern Trampoline.#696

Merged
iluwatar merged 5 commits into
iluwatar:masterfrom
besok:master
Feb 25, 2018
Merged

#677 add pattern Trampoline.#696
iluwatar merged 5 commits into
iluwatar:masterfrom
besok:master

Conversation

@besok
Copy link
Copy Markdown
Contributor

@besok besok commented Jan 8, 2018

Pull request title

Pull request description

  • Add readme, code,test.

For detailed contributing instructions see https://github.com/iluwatar/java-design-patterns/wiki/01.-How-to-contribute

@besok
Copy link
Copy Markdown
Contributor Author

besok commented Jan 8, 2018

Throttling test has failed.
I don't understand what i should do now.

@iluwatar
Copy link
Copy Markdown
Owner

It is a known issue #643

Copy link
Copy Markdown
Owner

@iluwatar iluwatar left a 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

Comment thread trampoline/README.md
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.


Copy link
Copy Markdown
Owner

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i added section,

Comment thread trampoline/README.md
* [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)

Copy link
Copy Markdown
Owner

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed it.

Comment thread trampoline/pom.xml
<version>1.16.18</version>
<scope>provided</scope>
</dependency>

Copy link
Copy Markdown
Owner

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.

Copy link
Copy Markdown
Contributor Author

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.*/
Copy link
Copy Markdown
Owner

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?

Copy link
Copy Markdown
Contributor Author

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.
*/
Copy link
Copy Markdown
Owner

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.

Copy link
Copy Markdown
Contributor Author

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{
Copy link
Copy Markdown
Owner

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Changed to testTrampolineWithFactorialFunction

@iluwatar
Copy link
Copy Markdown
Owner

@besok please comment when you've implemented the changes.

@besok
Copy link
Copy Markdown
Contributor Author

besok commented Jan 17, 2018

Ok. I am going to do it on holidays(20-21.01)

@besok
Copy link
Copy Markdown
Contributor Author

besok commented Jan 20, 2018

The project is missing from parent pom.xml

How can i add this modula to parent pom?
I added record to module section in parent pom.

@besok
Copy link
Copy Markdown
Contributor Author

besok commented Feb 1, 2018

@iluwatar , can you check my changes?

@iluwatar iluwatar merged commit 7fef5e4 into iluwatar:master Feb 25, 2018
@iluwatar
Copy link
Copy Markdown
Owner

Well done @besok 👍 Thanks for the new pattern!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants