Skip to content

Current architecture doesn't always achieve its goal #2

Open
@KyNorthstar

Description

@KyNorthstar

For example:

someFunction(specificSpecialStrings: someRawStrings.map(SpecialString.init))

Here, it's impossible to tell if you're creating the correct kinds of special strings; the special string type is assumed by the compiler.

Consider, instead, an architecture where SpecialString is a protocol that types can conform to, instead of a struct with a marker generic type associated with it:

someFunction(specificSpecialStrings: someRawStrings.map(Username.init))

Here it's clear that we're creating special Username strings. The compiler still assumes some stuff for us so it's not any more or less verbose, but it's obvious to maintainers and peer reviewers what's intended here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions