Issue #469: Event-based Asynchronous pattern#483
Conversation
|
Failed at Checkstyle. Working on it. |
|
Issue seems to be stemming from PMD check. I believe that it is due to the unnecessary "public" scope in IEvent. Will submit a fix before the end of today. |
|
Coverage decreased by ~1%. Is it still OK to merge? |
|
Hey, @iluwatar . Any thoughts on this so far? :) |
|
@waisuan My apologies for taking this long to review the pull request. Here are my comments:
|
| permalink: /patterns/event-asynchronous/ | ||
| categories: Other | ||
| tags: | ||
| - Java |
There was a problem hiding this comment.
Can you think proper categories and tags for the pattern? For reference see http://java-design-patterns.com/patterns/
|
@waisuan You have my review comments. Please comment on this thread once you're ready for another review. |
|
Thanks for getting back to me, @iluwatar . Your comments have been noted. I'll try to get to them sometime this week. Cheers. |
|
Hey, @iluwatar . I've made the necessary changes based on your feedback. Do take another look and let me know if there is anything else. Thanks! |
|
@waisuan here are my comments:
|
|
Hey, @iluwatar . Kindly take another look at my changes. The properties file accept "YES" or "NO" as its input. I've toggled the settings. They seem to work just fine. I've fine-tuned the interactive mode as well. It was meant to be a "fun" way of displaying the design pattern at hand; not take focus away from it. I can remove it if you like. I prefer not to complicate the interactive mode any further so that the focus on this design pattern can be the pattern itself. :) |
| title: Event-based Asynchronous | ||
| folder: event-asynchronous | ||
| permalink: /patterns/event-asynchronous/ | ||
| categories: Other |
There was a problem hiding this comment.
We should use Concurrency category
| System.out.println("Event [" + aEventId + "] has been stopped."); | ||
| eventManager.cancel(sEventId); | ||
| System.out.println("Event [" + sEventId + "] has been stopped."); | ||
|
|
There was a problem hiding this comment.
Can we change the output so that it tells whether we are talking about sync or async event. For example "Async event [xxx] has been created" and "Sync event [xxx] has been created"?
| } catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException e) { | ||
| System.out.println(e.getMessage()); | ||
| } | ||
| } |
There was a problem hiding this comment.
We should add tests to run operations from start to finish also. Create and start event and wait for it to finish. For async operations we could create multiple events and wait for all of them to finish.
| long endTime = currentTime + (eventTime * 1000); | ||
| while (System.currentTimeMillis() < endTime) { | ||
| try { | ||
| Thread.sleep(5000); // Sleep for 5 seconds. |
There was a problem hiding this comment.
I think the granularity should be 1 seconds instead of 5 seconds here.
|
Hey, @iluwatar . Your feedback has been noted. I'll get to them sometime this week. |
|
Gonna work on this today. :) |
|
Done, @iluwatar |
iluwatar
left a comment
There was a problem hiding this comment.
@waisuan the interactive mode cannot be triggered with a change to config.properties file. I changed the property to INTERACTIVEMODE=YES and ran the program in IntelliJ Idea. I also tried placing the config.properties file to the same folder as the produced event-asynchronous-1.14.0-SNAPSHOT.jar and running the jar with java -cp event-asynchronous-1.14.0-SNAPSHOT.jar com.iluwatar.event.asynchronous.App. The app still runs in non-interactive mode. Am I missing something or how does it work for you?
I propose you put the config.properties in src/main/resources to fix this issue.
|
Not sure what happened there, @iluwatar . It works on Eclipse. Regardless, I've moved the config file into a separate directory as suggested. |
|
@waisuan work well done! Thank you for the new pattern contribution 👍 |
Hey @iluwatar . Let me know if there are any issues with the implementation of the new pattern. Thanks.