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

Refactoring- Removed 3 design smells #856

Merged
merged 3 commits into from
Apr 2, 2024

Conversation

ashishbhasin45
Copy link

  1. Refactored to resolve cyclic dependency
    Location-
    Sub-Project: imixs-workflow-engine
    Package: org.imixs.workflow.engine
    Classes: AsyncEventScheduler and AsyncEventService

  2. Refactoring applied- Move method to increase cohesion.
    Location(s)- Sub-project: imixs-workflow-jax-rs
    Package: org.imixs.workflow.jaxrs
    Class: ModelRestService

    Sub-project: imixs-workflow-engine
    Package: org.imixs.workflow.engine
    Class: ModelService

    Sub-project: imixs-workflow-core
    Package: org.imixs.workflow
    Class: ModelManager
    ModelRestService was using ModelService’s methods quite a few times in its method printVersionTable. I moved the method to perform the desired operation in the ModelService where it belonged and then called that method once in the ModelRestService to get the output.
    The model was also defined in the ModelManager interface as ModelService implements it.

  3. Refactoring applied- Replace conditional with polymorphism.
    Location(s)- Sub-project: imixs-workflow-faces
    Package: org.imixs.workflow.faces.util
    Class: ErrorHandler

    Sub-project: imixs-workflow-faces
    Package: org.imixs.workflow.faces.util
    Class: ValidationException

    Sub-project: imixs-workflow-core
    Package: org.imixs.workflow.exceptions
    Class: PluginException

    Sub-project: imixs-workflow-core
    Package: org.imixs.workflow.exceptions
    Class: WorkflowException
    ErrorHandler class had conditionals in the addErrorMessage where it was checking the instance of PluginException and ValidationException and performing action based on that. I created a method formatErrorMessageWithParameters in the abstract class workflowException and overrode this method in PluginException and ValidationException child classes. In the ErrorHandler class I changed the conditional with the call to this new method and based on the object type it will perform desired behavior.

Copy link
Member

@rsoika rsoika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's amazing! Great and thanks again for your contribution 🥇

I have just two comments:

  • We can place the method formatErrorMessageWithParameters directly into the WorkflowException. This is a good place and your method makes of course sense. And so we can leave the other Exceptions Types as the are

  • Place the method modelVersionTableToString into the ModelRestService as this is a very specific part of the REST API. The ModelService in the Engine package should not handle this part.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets move this method into the abstract class WorkflowException

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets move this method into the abstract class WorkflowException

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the implementation of this method in both pluginException and validationException as the implementation is dependent on the params field of these classes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this now in the Issue #857 . This simplifies the code much more and we have the feature now for all Imixs Exception Types.
Thanks for you contribution!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this as we can have a valid implementation directly in the abstract WorkflowException class

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the method which was defined in interface modelManager and overriden in model service, now I have moved it to modelRestservice as per your suggestion, and it no longer a part of the modelManager hence not required to be overriden here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just put the implementation here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand your attention, but lets have the method modelVersionTableToString still in the ModelRestService as this is a very specific part of the REST API

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the function to modelRestService.

Copy link
Member

@rsoika rsoika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@rsoika rsoika merged commit 0328b53 into imixs:master Apr 2, 2024
1 check passed
@rsoika rsoika mentioned this pull request Apr 2, 2024
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

Successfully merging this pull request may close these issues.

2 participants