Skip to content

Use of Design Patterns to improve code maintainability #1

@amadoran

Description

@amadoran

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions