sirix icon indicating copy to clipboard operation
sirix copied to clipboard

Issue#523: Refactor XML and JSON handling in CRUD operations

Open omkar-shitole opened this issue 1 year ago • 4 comments

[WIP] Initial Refactoring of XML and JSON handling in CRUD operations

Overview

This PR introduces to handle common logic for XML and JSON operations in the CRUD directory. The focus is on enhancing abstraction for create and delete operations, to reduce code duplication and improve maintainability.

Changes

  1. AbstractCreateHandler Enhancement:
    • Extended with implementing Common Method createDatabaseIfNotExists()
    • Refactored XMLCreate and JsonCreate to use this shared method.
  2. AbstractDeleteHandler Enhancement:
  • Extended with implementing Common Method handle()
  • Refactored XMLDelete and JsonDelete to use this shared method.

Next Steps

  • Review and refine current changes based on feedback
  • Extend similar refactoring to other operations.
  • Consider creating abstract base classes for classes which have almost similar methods and content.

Review Request

Please focus on:

  1. Effectiveness of the abstraction and adherence to "Template Method" design (Interface+Abstact+Implementations)
  2. Potential issues with format-specific operations
  3. Suggestions for further improvements or extensions of this refactoring approach

omkar-shitole avatar Aug 26 '24 04:08 omkar-shitole

Thanks so much for opening this pull request and for helping to improve SirixDB 🚀

welcome[bot] avatar Aug 26 '24 04:08 welcome[bot]

Looking good :-)

JohannesLichtenberger avatar Aug 26 '24 10:08 JohannesLichtenberger

Are you going to add more stuff or should I already merge?

JohannesLichtenberger avatar Aug 26 '24 10:08 JohannesLichtenberger

Thank you for your support. Definitely, I will extend similar refactoring to other operations wherever possible and commit the changes in the PR.

omkar-shitole avatar Aug 27 '24 06:08 omkar-shitole

[Revised] Further Refactoring of XML and JSON Handling in CRUD Operations

Overview

This PR continues the refactoring and modifications to enhance XML and JSON handling within CRUD operations.

Changes

  1. AbstractGetHandler Enhancement:

    • Added common methods for data retrieval within AbstractGetHandler.
    • Refactored JsonGet and XmlGet to leverage these shared methods for centralized retrieval logic.
  2. AbstractUpdateHandler Introduction:

    • Introduced AbstractUpdateHandler to manage update operations across both contexts.
    • Updated JsonUpdate and XmlUpdate to extend AbstractUpdateHandler, ensuring consistent update handling.

Next Steps

  • Review and provide feedback on the newly implemented abstractions.

Review and Merge Request

Kindly review the changes.

2d9cadb52efde102afc5b5cd6d34117880aae0a4

omkar-shitole avatar Aug 30 '24 17:08 omkar-shitole

Thanks a lot, I think it's great regarding clean code, but I'm on my phone, so I'll check tomorrow or later on :-) thanks a lot and as always I hope you'll contribute more ;) there's maybe room for a better Kotlin DSL API, maybe even a DSL to provide type safe and syntactically correct JSONiq. Other than that I'm currently working on reducing object allocations :-)

JohannesLichtenberger avatar Aug 31 '24 19:08 JohannesLichtenberger

Oh and maybe updating Vert.x to the newest version and check if we have to update anything.

JohannesLichtenberger avatar Aug 31 '24 19:08 JohannesLichtenberger

Congrats on merging your first pull request. 🐬 You've just improved SirixDB for everyone. ❤️

welcome[bot] avatar Sep 03 '24 15:09 welcome[bot]