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

Current architecture doesn't always achieve its goal #2

Open
KyLeggiero opened this issue Oct 22, 2019 · 0 comments
Open

Current architecture doesn't always achieve its goal #2

KyLeggiero opened this issue Oct 22, 2019 · 0 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@KyLeggiero
Copy link
Collaborator

KyLeggiero commented Oct 22, 2019

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.

@KyLeggiero KyLeggiero added bug Something isn't working enhancement New feature or request labels Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant