Skip to content
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

Merged
merged 27 commits into from
Mar 10, 2024
Merged

feature: Add gateway pattern (#1297) #2734

merged 27 commits into from
Mar 10, 2024

Conversation

FinnS-F
Copy link
Contributor

@FinnS-F FinnS-F commented Oct 25, 2023

Gateway Pattern

@FinnS-F FinnS-F closed this Oct 25, 2023
@FinnS-F FinnS-F reopened this Oct 25, 2023
@FinnS-F FinnS-F closed this Oct 25, 2023
@FinnS-F FinnS-F reopened this Oct 25, 2023
@FinnS-F FinnS-F mentioned this pull request Oct 25, 2023
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 7 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

Copy link

stale bot commented Nov 27, 2023

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.

@stale stale bot added the status: stale issues and pull requests that have not had recent interaction label Nov 27, 2023
category: Structural
language: en
tag:

Copy link
Owner

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);
Copy link
Owner

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)

Comment on lines 27 to 34
/**
* 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.
*/
Copy link
Owner

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

Comment on lines 31 to 38
class ExternalServiceA implements Gateway {
@Override
public void execute() throws Exception {
System.out.println("Executing Service A");
// Simulate a time-consuming task
Thread.sleep(1000);
}
}
Copy link
Owner

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?

Copy link
Contributor Author

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.

@stale stale bot removed status: stale issues and pull requests that have not had recent interaction labels Dec 28, 2023
@FinnS-F FinnS-F reopened this Jan 3, 2024
Copy link

sonarqubecloud bot commented Jan 3, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

stale bot commented Feb 2, 2024

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.

@stale stale bot added the status: stale issues and pull requests that have not had recent interaction label Feb 2, 2024
Copy link
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.

Couple of minor comments, but I'll merge

category: Structural
language: en
tag:
- Gang of Four
Copy link
Owner

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");
Copy link
Owner

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

@stale stale bot removed the status: stale issues and pull requests that have not had recent interaction label Mar 10, 2024
@iluwatar iluwatar merged commit 2d54709 into iluwatar:master Mar 10, 2024
2 checks passed
@iluwatar
Copy link
Owner

@all-contributors please add @FinnS-F for code

Copy link
Contributor

@iluwatar

I've put up a pull request to add @FinnS-F! 🎉

@iluwatar
Copy link
Owner

#2818

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants