-
Notifications
You must be signed in to change notification settings - Fork 4k
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
naming conventions: 'add' methods #1741
Comments
+1 Another thing we should enforce via awslint is that Then, I was also thinking that we can implement deCDK heuristics for the "adds" since they can be represented as an array: {
capacity: [
{ "id": "machine", desiredCapacity: 5 } // kwargs at play
]
} |
Do you mean "news"? |
No, I was even thinking we can probably enforce this at the awslint level: if a construct has an |
I am having second thoughts about Why is it important to distinguish between "new" and "add"? |
Completely for user ergonomics and managing user expectations. The
If we called everything These kinds of conventions are even more important for untyped languages like JavaScript and Python, where the IDE (potentially) doesn't help as much. |
I don't think that this is something we should/want to standardize actually. For example, I think the only thing that makes these methods "special" is that they return an object, and this is captured in the method signature, so I don't really think it requires that the method name will encode this as well. |
We have methods named
foo.addBar()
which do two different things:bar
object and relate it to thefoo
somehow.bar
object (typically using some properties fromfoo
to make the API nicer), relate it tofoo
, and then return it.Examples:
I propose that we rename all methods that create new constructs to
newBar()
and their signature must always befoo.newBar(id, props)
The type should probably be called
Props
instead ofOptions
(see #1740)The text was updated successfully, but these errors were encountered: