Attributes #34
mattesmohr
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
Here I think it is best to choose one method. And here I like the first path the best. Adding required attributes in the init, and then making it possible to add optional attributes afterwards. Even tho it is a bit more effort, I find it cleaner and harder to make user mistakes. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There exist some attributes, wich are exclusive for a specific element. For example:
So I was wondering if we should include the attribute as a parameter in the initialiser instead of a possible function. I have seen, you have done it in the past for one element. I would write it for each element, wich has such an exclusive attribute.
SwiftUI does it aswell. For example:
So I tried to find out, when SwiftUI is doing it, and when it doesn't. The only answer I came up with, is that SwiftUI prefers the parameter instead of the punctuation, when the element depends on the attribute. Like the VStack needs to know the alignment to understand how the content should be displayed. For example:
The input itself is nothing without the type definition. Its like a required attribute. But since the type-Attribute is used by many elements. For example:
From a coder perspective its totally fine two write a protocol here. It means less code duplication, right?
So I think we have three options here:
Pro: Less code (at least I think). Less errors, since the initialisers gives right away, that some parameters are needed. Less attribute-stacking.
Instead:
Contra: More effort to implement.
Pro: Everything is the same. There is no exception. Attributes means Punctuation.
Contra: Maybe more errors.
Pro: The user has a choice.
Contra: More Effort. Maybe some code confusion.
Beta Was this translation helpful? Give feedback.
All reactions