SynBioDex-archive / libSBOLcore

The core Java models of SBOL
6 stars 0 forks source link

Collection.components and DnaComponent.annotations should preserve order #5

Closed timothyham closed 13 years ago

timothyham commented 13 years ago

Looking at ea4b67814161ec2cbb92, It seems to me the components and annotations orders matter. Users will get confused if order of annotations change when they save and reopen objects. As such, I'd suggest using LinkedHashSet instead of HashSet.

drdozer commented 13 years ago

If order matters, then the interface used should really be List. However, my 'are we yack shaving' question would be:

timothyham commented 13 years ago

It's not that the order of adding matters, but rather they should come out as ordered by genbankStart. It would be nice to be able to call Sort on this collection.

drdozer commented 13 years ago

For the Java verison, it's easy to add

class SequenceAnnotation {

  ...

  public static final class ByStart extends Comparator<SequenceAnnotation> {
    public int compareTo(SequenceAnnotation other) {
      return other.getGenbankStart() - this.getGenbankStart();
    }
  }
}

What is the use-case where your program fails if it doesn't get out SequenceFeatures in start order? Is it just a convenience, or is it something that a normal user will need to rely upon? It places a burden upon all implementations, and requires documenting, so it's not zero cost to us.

timothyham commented 13 years ago

Ok, I can't think of a use case where SequenceFeature has to be stored in order, nor cases where there would be duplicate SequenceAnnotations. I'll close this issue.

drdozer commented 13 years ago

Fine. If we have use-cases for this then we should re-open the issue. I've opened a related issue #16 dealing with identity for sequence annotations, as we do not wish to allow duplicates.