-
-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feature: Add gateway pattern (#1297) #2734
Conversation
Fixed pom.xml
SonarCloud Quality Gate failed. 0 Bugs 0.0% Coverage Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
gateway/README.md
Outdated
category: Structural | ||
language: en | ||
tag: | ||
|
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.
remove empty line
serviceB.execute(); | ||
serviceC.execute(); | ||
} catch (ThreadDeath e) { | ||
System.out.println("Interrupted!" + e); |
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 a proper logger (Lombok's slf4j annotation works)
/** | ||
* The App class serves as the main entry point for the application implementing the Gateway design pattern. | ||
* It demonstrates the use of the GatewayFactory to manage different gateway implementations, allowing for the | ||
* execution of various services asynchronously. | ||
* | ||
* <p>In this example, there are three virtual service. GateFactory is the factory class and it provides a method | ||
* to create different kinds of external services. | ||
*/ |
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.
Explain briefly the pattern and how the example code implements it
class ExternalServiceA implements Gateway { | ||
@Override | ||
public void execute() throws Exception { | ||
System.out.println("Executing Service A"); | ||
// Simulate a time-consuming task | ||
Thread.sleep(1000); | ||
} | ||
} |
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.
Services A, B and C seem to be similar. Could we implement them with a single class?
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 have modified my code based on your review. For the last point you mentioned, these classes are just virtual implementations of external services. They may look the same(print out some string), but actually they are responsible for different functionalities.
This reverts commit f31a00c.
# Conflicts: # pom.xml
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
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.
Couple of minor comments, but I'll merge
category: Structural | ||
language: en | ||
tag: | ||
- Gang of Four |
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 think this is not included in the original GoF patterns
class ExternalServiceA implements Gateway { | ||
@Override | ||
public void execute() throws Exception { | ||
System.out.println("Executing Service A"); |
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.
These should be updated to logger instances
@all-contributors please add @FinnS-F for code |
I've put up a pull request to add @FinnS-F! 🎉 |
Gateway Pattern