2
votes
1answer
121 views

What are the pros and cons of temporary variables vs multiple returns [duplicate]

Take the following examples: public static String returnOnce() { String resultString = null; if (someCondition) { resultString = "condition is true"; } else { resultString ...
-3
votes
3answers
295 views

In what practical ways is it good to remember the memory/pointers model? [closed]

A variable refers to a value. A variable is also stored in a memory address. People say that it's good to have this memory model in mind. Is that true? What is some sample code that shows this as ...
34
votes
15answers
3k views

Is it bad practice to name an unused variable with a single underscore?

Often when the syntax of the language requires me to name a variable that is never used, I'll name it _. In my mind, this reduces clutter and lets me focus on the meaningful variables in the code. I ...