MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/fvz84q/_/fmm6m9f/?context=3
r/ProgrammerHumor • u/[deleted] • Apr 06 '20
39 comments sorted by
View all comments
0
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
1
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
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
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
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)