While I agree the medical example is not medically accurate, I was just using it as an example of how descriptive I think variables should be. Obviously, I don’t expect anyone to write such long variable names that the code becomes unreadable like ‘variableThatMeansSomethingAndAlsoSomethingDependingOfTheMoonPhase’ considering that that wouldn’t make sense to write, and it doesn’t make that variable anymore descriptive by adding filler words.
From an object-oriented perspective, like you mentioned creating a Patient object, obviously attributes would handle most of the details, and the boolean “patientIsSedatedWithTumorOnLeftSideOfBrain” would not be needed.
My main objective was to bring across how important naming variables are, and to not be afraid of having names that are a bit long, just for the sake of convenience.
I have seen many times, not only in code written by students, but by code written by software engineers where they name variables as “t1” or “t2” or something else quick just to get their code completed. I just think it’s really important to be as descriptive as possible, within reason of course, to establish good, readable code. Obviously, I am against anything that would hamper the ability to make code readable, so I definitely would be against writing unreasonably long variable names that would make reading code more difficult.
An example that comes to mind of other people who have similar ideas with regards to long variable names is Paul Hegarty. He is a professor at Stanford with a fantastic class on iPhone development. In Lecture 1, he creates a boolean called “userIsInTheMiddleOfTyping”, and emphasizes how important it is to have descriptive variable names. Maybe Professor Hegarty’s example of a long variable name would have been better in this case, but still the point gets across. Writing descriptive variables, and not worrying about the length is vital. I don’t expect people to write unreasonably long names after reading this article like I said before, but I certainly hope that people think twice before writing a variable name that isn’t descriptive, so that they can make their code more readable.
Just to reiterate, yes, don’t make long variable names for no reason; I agree with that logic. Yes, from OOP perspective my medical example would not need that long of a variable name, and the example clearly was not medically accurate. But, once again, this article was written in the hopes that people will take the time out to write more variable names like “popcornIsEmpty”, “numberOfStudentsPresent”, or “businessesAcquired”. The medical example obviously is extreme, and most often you won’t need to provide a name that long, but in general I hope that people will write better variable names like the ones above.
I have removed the medical example, but I still think the popcorn example was good, and it brought my point across. Thanks for making that note about the medical example, the changes are reflected in the article now.