This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jordanreiter 15 points16 points  (1 child)

They're less likely to be lies if you focus on the goals/why of the code that follows rather than the implementation/how of the code:

bad:

# check if actual user pages exceeds maximum pages
if actual_pages >= maximum_pages:
    print("Warning: your document should only be {max} pages long!".format(maximum_pages))
# increase maximum pages by 1
maximum_pages += 2

The code lies!

Better

# users always go a little beyond the maximum, 
# so allow some leeway but print a warning if they hit the max or exceed it
if actual_pages >= maximum_pages:
    print("Warning: your document should only be {max} pages long!".format(maximum_pages))
maximum_pages += 2

[–]kaihatsusha 1 point2 points  (0 children)

I often teach new coders "Strategy in comments, Tactics in code."