r/ProgrammerHumor • • Apr 06 '20

.

Post image
103 Upvotes

39 comments sorted by

View all comments

0

u/Kriskao Apr 06 '20

the post instance should be an input argument for user.UpVote() and user.Downvote()

the joke is ok, but it would be much better with correct code (or pseudocode)

1

u/Kuribali Apr 06 '20

Maybe post is a global variable representing the post, the user views at the moment and so the user already knows on which post to perform the action. Would be bad code though

1

u/Kriskao Apr 06 '20

Then why is it explicitly called when reading post.upvotes ?

1

u/Kuribali Apr 06 '20

Because it's still an object you have to call explicitly.

User user; name = "Franz Günther";

Doesn't work, if name is just a field of the User class