Skip to content

Create top-level types.go to define types shared across packages #347

@carreter

Description

@carreter

Is your feature request related to a problem? Please describe.
As poly grows, more and more types will be shared between nominally unrelated packages.

For example, many packages will deal with sequences. Currently, we use the string type to represent sequences in most of the packages. However, sequences often also need to be annotated with whether they are circular or linear, as is already done in the clone package and as we are considering doing to resolve #225 :

https://github.com/TimothyStiles/poly/blob/10b8f398c4272700dd27a177af244d6b531d2582/clone/clone.go#L56-L63

Describe the solution you'd like
A new file (types.go) in the root of the repository that defines types commonly used across packages. Whenever it feels like you're reusing a similar struct or interface across packages, it should be placed in said file.

Describe alternatives you've considered

  • Place the shared types in a package (e.g. types or common)
    • Pros: Will keep the top level of the package cleaner
    • Cons: feels unnecessary, adds another level of indirection to package imports
  • Divide up poly into more specific packages that share common types
    • Anything that deals with a sequence will be put in the package sequence. Anything that deals with structural info will be put in the package structure. These packages will have a top-level types.go file that contains shared types.
    • Pros: Might be necessary in the future as we add more functionality anyway. Even now, the top level of the package is getting a little crowded.
    • Cons: Adds another level of indirection to package imports, currently feels unnecessary as we only have sequence-based tools. Might cause import cycles for some types.
  • Do nothing.
    • If it ain't broke, don't fix it. And it definitely ain't broke here in that it doesn't block development/use of poly, but I still think this needs addressing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    easyA quick and easy fix!proposalA proposed feature or enhancementquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions