Comments cannot enforce types or usage.

Use code for this.

Don’t make a comment saying a variable should be a certain type. Although the statement is true, this will lead to bugs when the “rule” is violated.

Enforce rules with types, objects, assertions, logic, and other code constructs. Make the code work at validating itself.

Note this doesn’t apply to some annotations, these actually work. These are a special kind of comment that gets read by the preprocessor and turned into code.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: