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

Use of Design Patterns to improve code maintainability #1

Open
amadoran opened this issue Dec 27, 2022 · 0 comments
Open

Use of Design Patterns to improve code maintainability #1

amadoran opened this issue Dec 27, 2022 · 0 comments

Comments

@amadoran
Copy link

Chain of Responsabilty Pattern.
The main reason to use this pattern is that in the EventManagementSystem class the two methods clientLogin and AdmiLogin have a peculiar way of behaving and if we realize they must make a chain of validations, therefore, we should apply the design pattern “ chian of responsibility”, in order to optimize the process and instead of using methods for each type of login, we will use classes that generalize the process.
image

Strategy Pattern.
Analyzing the behavior of this code, we can notice that it has several nested ifs, with this in each condition we notice that it is a different way of doing the operation. Taking this as background, we can notice that we can divide it into strategies to make these calculations and thus avoiding the nested if statement.
image

The solution:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant