Skip to content

naming conventions: data types (Props & Options) #1740

Closed
@rix0rrr

Description

@rix0rrr

We need to have a naming convention around data objects, used as (optional) keyword arguments.

They are used for three purposes:

  • To configure a Construct, via its constructor (example: new Bucket(scope, id, PROPS)).
  • As options to a function or method, that customize its behavior (example: eventRule.addTarget(target, TEMPLATE))
  • To configure a Construct indirectly, via a method on an existing construct (example: loadBalancer.addListener(id, LISTENERPROPS))

In the TypeScript/JavaScript world, data objects used for configuration are usually called options or opts.

In the CloudFormation world, input data for configuring resources are called properties.

Because of our duality (mapping between programming and CloudFormation), we are split between calling these data objects properties and options.

  • For the arguments to a constructor, we've most definitely settled on props, e.g. BucketProps.
  • For the arguments to a method, we've varying between props and options.
  • Same as for methods that construct a new construct.

I propose that we adopt the rule: Props for construct, Options for methods.

So in the examples above, the type names for the configuration objects would be:

  • BucketProps, no change.
  • AddTargetOptions.
  • AddListenerOptions.

Thoughts?

Metadata

Metadata

Assignees

Labels

@aws-cdk/coreRelated to core CDK functionalitypackage/awsclCross-cutting issues related to the AWS Construct Library

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions