2 ms·
My rule is really simple to explain to a junior - "don't use any inline side effects." How do you explain your rule to a junior? You're going to have to tell t
by chrisseaton 8y ago
My rule is really simple to explain to a junior - "don't use any inline side effects."
How do you explain your rule to a junior? You're going to have to tell them that inline side effects are fine, as long as you follow another set of rules about sequencing - a set of rules you admit most people don't know at all and fewer people understand correctly!
- Dylan16807 8y agoI guess I was unclear. You don't need to know the sequencing at all. It doesn't matter. My rule would be "If you side-effect a variable, don't use it anywhere else in the same line". I think that's plenty simple. Edit: Another way of wording my rule would be "if you have to care about sequencing, don't do it"
- watwut 8y agoI use rules I can defend. Be defense, I mean can explain impact on readability or maintainability - personal preferences dont count. E.g., if I have to use "I don't like it" then it is bad rule. Also, I deal with code in question, not with imaginary different code. This particular line is plenty readable and maintainable. People typically don't know about X is argument, but then people really typically must make mistakes about X. This is shared industry standard is an argument, but again, then is must really be industry habit. Not just me wanting it to be so. Also, if the junior cant comprehend reasoning, he/she will have hard time with expressions like "inline side effects". The word inline is not much used in Java world. If there is style guide, then it is different matter and the argument is about usefulness of style guide itself (e.g. you follow the rule unless rule harms, even if the rule is overly broad). Absent style guide, imposing your personal preferences on good lines, because entirely different line would be unreadable is not something I can support. I used to follow such instructions, but don't anymore because such blind follow tactic lead to all kinds of problems for me. When I worked with juniors, I wanted them to understand so that they can make own decisions as soon as possible. I did not wanted them to memorize hundreds of random rules.