Skip to content

[Code] Placement of parsing and writing logic #888

@tobiasdiez

Description

@tobiasdiez

Right now parsing and serialization is not handled in a uniform way. (see e.g #875)

Possible designs which come to my mind:

  • The BibParser and BibWriter contain all the logic as private methods.
    • e.g.: BibParser.parseMetaData(String stringyMetadata) and BibWriter.writeMetaData(Metadata)
    • pro: encapsulation of responsibilities
    • contra: rather big classes BibParser and BibWriter, hard to test
  • There are transformer classes which just convert the string to the object and vice-versa.
    • e.g.: MetadataTransformer with static parse(String stringyMetadata) and static write(Metadata) [suggestions for a better name then transformer? ReadWriter?]
    • pro: encapsulation of responsibilities (but weaker as 1), can be reused somewhere else, better testability
    • contra: exposes writing and parsing to the outside world, many new classes
  • The corresponding objects have methods which allow parsing and converting to string.
    • e.g.: Metadata has static parse(String stringyMetadata) [or constructor?] and serialize()
    • pro: encapsulation of responsibilities (but weaker as 1 and 2), can be reused somewhere else, better testability as 1
    • contra: exposes writing and parsing to the outside world, scatters parsing and writing logic

I have no strong opinion about which option we should use (slightly preferring 2), but we should decide for one to handle parsing and writing uniformly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions