Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new abstract SequenceType #43

Open
2 tasks
HawkSK opened this issue Sep 1, 2020 · 0 comments
Open
2 tasks

Introduce new abstract SequenceType #43

HawkSK opened this issue Sep 1, 2020 · 0 comments

Comments

@HawkSK
Copy link
Contributor

HawkSK commented Sep 1, 2020

Proposition

Currently, all types representing a sequence (collection) extend ComponentType. However, also OptionalType is a ComponentType. A new intermediate empty abstract type uniting all sequence types is proposed, so that:

{ArrayType, ListType, ListTypeWithShared, OrderedSetType, SetType} <: SequenceType <: ComponentType
OptionalType <: ComponentType

Motivation

This will help in determining which types represent a sequence in an extensible way. Up until now, you could check this either by enumerating all seqence types (which will leave some out in the future):

if (type instanceof ArrayType || type instanceof ListType|| type instanceof ListTypeWithShared
    || type instanceof OrderedSetType|| type instanceof SetType) { }

Or by a more error-prone non-extensible, I dare say incorrect way:

if (type instanceof ComponentType && !type instanceof OptionalType) { }

The latter will cause problems in existing code in the future, when there is another non-sequence ComponentType introduced.

Tasks

  • create SequenceType and change the inheritance hierarchy

  • refactor all usages of ComponentType and OptionalType

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant