Skip to content

Use not-so-generic names for types. #59

@greymistcube

Description

@greymistcube

In my opinion, names such as Binary, List, Text are too generic and prone to naming collisions. It might not be much of a problem within this project, as a low level library, it isn't unreasonable high level applications might already be using List, Text, etc. Two main problems arise frequently when there are two Text types such as Bencodex.Types.Text and some App.Text:

  • It isn't immediately apparent which Text type is being used at a glance. Yes, in most cases, it can be derived from context and IDEs help, but this still is unnecessarily confusing.
  • Again, it is also often likely to happen both Text types are needed in a single source file since the whole point of Bencodex.Types.Text is to encode string or App.Text, in which case either unnecessary aliasing or fully qualified names are needed.

Honestly, I think it'd be better to name such types as BList, BText, etc. like here. There are pros and cons but I'd say overall the benefits outweigh the costs. As we have no control over the naming scheme in end-user's codebase, we should do as much as possible to avoid name collisions happening in the first place.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions