Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Conversation

@inonwir
Copy link

@inonwir inonwir commented Jun 25, 2025

Refactor XML Export Logic for Stream Reusability and Maintainability

Summary of Changes
This pull request introduces a focused refactor of the XMLImportExport class to improve modularity, code reuse, and maintainability by:

  • Extracting XML export logic into a new method: writeToStream(...)
  • Updating the existing exportToFile(...) method to reuse the writeToStream(...) logic
    -Preserving all existing behavior with no breaking changes

Motivation
The original export method tightly coupled file output with XML logic. By decoupling this into a reusable writeToStream() method:

  • The code becomes easier to test and maintain
  • Future developers can extend the export destination (e.g., memory buffer, network stream) without duplicating logic
  • Improves separation of concerns between stream writing and file I/O

Technical Details
writeToStream() takes an XMLEventWriter and handles the full RSS/XML generation process, including headers, molecule records, and units

  • The exportToFile() method now simply opens a file stream and passes it into writeToStream()
  • No logic changes to importFromFile() — only the export path is refactored

Backward Compatibility
This change does not break existing code. The exported files will remain identical, and external consumers using exportToFile() will not be affected.

Refactor XML Export Logic for Stream Reusability and Maintainability
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant