@unclebobmartin @JaviSoto @H9RBSjs how can you communicate the why's of your code without comment?
-
-
Replying to @buunguyen
@buunguyen Choose a good function names and good variable names.1 reply 0 retweets 1 like -
Replying to @unclebobmartin
@unclebobmartin that helps specify what the code does and how it does that; but not *why* it has to do it and/or do it that way1 reply 0 retweets 1 like -
Replying to @buunguyen
@buunguyen If your code is insufficient, then write a comment. But strive to make your code sufficient. Comments are a last resort.3 replies 5 retweets 1 like -
Replying to @unclebobmartin
@unclebobmartin@buunguyen def is_minor_but_19_counts_because_of_some_business_rule?;@age <= 19; end #??!? "why" is hard to capture in code1 reply 0 retweets 0 likes -
Replying to @davetron5000
@davetron5000 Note that you captured the "why" in the code. Using the function name is better than using a comment.1 reply 0 retweets 0 likes -
Replying to @unclebobmartin
@unclebobmartin that name is unwieldy and less readable than a simple comment in the code explaining things. Imagine a more complex reason…1 reply 0 retweets 0 likes -
Replying to @davetron5000
@davetron5000@unclebobmartin is this hypothetical code? what would your preferred name be and what would your preferred comment be?1 reply 0 retweets 0 likes -
Replying to @saturnflyer
@saturnflyer@unclebobmartin def minor?@age <= 19 # Initrode legal requires 19, see some_link end as a simple example1 reply 0 retweets 0 likes -
Replying to @davetron5000
@davetron5000@saturnflyer@unclebobmartin in that case I think a comment makes sense. I still think "comments are a last resort" is valid2 replies 0 retweets 0 likes
@pjb3 @davetron5000 @saturnflyer @unclebobmartin I love deleting comments after rewriting code to be clear enough it no longer needs one
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.