crap coding for myself. What variable names do you use?
-
so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?
To err is human to really elephant it up you need a computer
-
so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?
To err is human to really elephant it up you need a computer
It seems like I am the only one, but I am with you on this one... sort of. The only non descriptive variables I use for i, j & k in for loops. This is a throw back to my Fortran programming days. i, j & k were integers, other letters were floats. However. When I say descriptive, I do use names like 'something', 'stuff', 'thisOne', 'thatThing', etc. Sometimes, these do creep into production code, but not in a way that is confusing to the future being that has to deal with my code.
Nothing succeeds like a budgie without teeth.
-
so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?
To err is human to really elephant it up you need a computer
-
so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?
To err is human to really elephant it up you need a computer
Nope, my OCD won’t let me do such things. Quick an dirty code as well as production get the full treatment!
-
so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?
To err is human to really elephant it up you need a computer
Well, if I'm writing a very short procedure purely as a way to check it works or compare two methods that have occurred to me, and am probably doing it in a test rig, then yes, I will use short variable names for speed. But I do it properly when I rewrite the code into the actual program. One thing I will admit to: if I write a short utility function, one or two lines... you know, to return a filename without the extension, or the _n_th word in a string or something... I will often use astr, x etc. And counters are i. Always. Unless there is a nested loop, in which case one of them is j. Unless the code is long and complicated, in which case one is outer and the other inner. Should I hang my head in shame? [Please specify precise angle]
-
so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?
To err is human to really elephant it up you need a computer
When learning the language (C++) I utilize class names cfoobar cgoobar and choobar as needed. Never needed a cjoobar. Also as per FORTRAN i often utilize i j k for loop counters. Otherwise I utilize descriptive variable names even lengthy ones unless the lengthy type name is conveniently nearby to provide the context.
-
so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?
To err is human to really elephant it up you need a computer
I don't object to others doing that, but to think about code I do better to "think in code".
So the comments about "habits" really apply here. If any identifier is unconventional/silly I won't be focused on the intent of the code.
Secondly - the code that I do as a "one-off" often turns out to be useful and adopted in another project or context. It drags down my time and effort if I need to go back and tidy up and refactor.
Lastly - I was part of a moderately sized audience for a product demonstration once. As often happens the "presentation gods" were unkind. The demo started going awry and exposing all kinds of errors, exposing dopey-silly stuff that the developers probably NEVER intended to be part of a marketing demo.
I felt awful for the marketing guy that had to tap dance around to try to save this humiliating, failing pitch. -
so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?
To err is human to really elephant it up you need a computer
Yes, but only in a situation like this: 1) I need to change something in a database, that is really complicated to do using only SQL instructions. 2) Using any of my programs, I create a new button. I never use the name proposed by Visual Studio, but in this case it does not matter :) 3) I create the code I need to modify the database (Read data, change it, write it back) 4) I run the program and go to the module that has my button. 4a) Of course, I press the button. 5) The job is carried on. 6) I stop the program. 7) I delete the button That's it. The button's life is just the time it takes to change my database. (Or whatever stuff must be done)
-
so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?
To err is human to really elephant it up you need a computer
Never in production code. Many of my solutions include a "scratch" project which I use as a testbed for writing code like you mention. The app never sees the light of day. The code never gets pasted from that app to the real apps.
Real programmers use butterflies
-
so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?
To err is human to really elephant it up you need a computer
Well, it VARIES. (Obligatory Answer). Like many here, I use i,j,k, and occasionally other single letters for loops and counters. It's habitual enough that their purpose actually screams out "I am a counter". But, in general, I do it in camelCase because it's eye-friendly to me and follow the following: "If you don't have time to do it right the first time, how will you find the time to do it again?"
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010
-
so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?
To err is human to really elephant it up you need a computer
IBHosed - variable for checking connections
-
I'm with Marc: never. Why not? Because you will not find the time to go back and correct it - it will be permanent. That's why I "do it right" even for throwaway apps: parameterized queries, proper names, no default control names from Visual Studio, and so forth. Do it right all the time, and you don't get into bad habits which enter production cycle.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?
To err is human to really elephant it up you need a computer
I tend to use descriptive names. I keep this code around for 10 years (yep, 10 years) and I've discovered I sometimes need to go back to it. Now the oddest name I used was the loop control in a language that didn't have infinite loops. The loop was (old ALL CAPS language) DO .... UNTIL HELLFREEZESOVER Unfortunately that program terminated in 2004 when the Red Sox won the World Series. :)
-
so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?
To err is human to really elephant it up you need a computer
Code right or code not. There is no try. :)
-
Code right or code not. There is no try. :)
From the original post... Does anyone else do this? Absolutely not. I learned a long time ago that a lot of POP code becomes production code. Like one of the other respondents posted... Code right or code not. There is no try.
-
It seems like I am the only one, but I am with you on this one... sort of. The only non descriptive variables I use for i, j & k in for loops. This is a throw back to my Fortran programming days. i, j & k were integers, other letters were floats. However. When I say descriptive, I do use names like 'something', 'stuff', 'thisOne', 'thatThing', etc. Sometimes, these do creep into production code, but not in a way that is confusing to the future being that has to deal with my code.
Nothing succeeds like a budgie without teeth.
Wizard of Sleeves wrote:
I use for i, j & k in for loops
I have the same less-than-great habit, also a hangover from my FORTRAN days (the fact that I type FORTRAN in upper case tells you how long ago that was). I have moderated the habit a little over the years, often making the names of the form
_ABC_i
where the_ABC_
prefix is a descriptive acronym for the array being indexed.Software Zen:
delete this;
-
I don't object to others doing that, but to think about code I do better to "think in code".
So the comments about "habits" really apply here. If any identifier is unconventional/silly I won't be focused on the intent of the code.
Secondly - the code that I do as a "one-off" often turns out to be useful and adopted in another project or context. It drags down my time and effort if I need to go back and tidy up and refactor.
Lastly - I was part of a moderately sized audience for a product demonstration once. As often happens the "presentation gods" were unkind. The demo started going awry and exposing all kinds of errors, exposing dopey-silly stuff that the developers probably NEVER intended to be part of a marketing demo.
I felt awful for the marketing guy that had to tap dance around to try to save this humiliating, failing pitch.Pete Kelley wrote:
I felt awful for the marketing guy that had to tap dance around to try to save this humiliating, failing pitch
Wow. It must have really been awful. In my case if I saw a marketing guy drowning in gasoline, I'd hand him a lit match...
Software Zen:
delete this;
-
so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?
To err is human to really elephant it up you need a computer
Err... I would never hire you if I was an interviewer. I name everything properly, even in a throw away / practice program. Habit is something that's hard to change. Have a good habit.
-
so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?
To err is human to really elephant it up you need a computer
I think you should always make the decision before you code: Is it one-way disposable code or is it production-level clean code. The latter can take up to twice as much time, so you should decide carefully. So when you decide to use throw-away code in production, you *have* to invest some more time to make it nice and neat. At least that's the way I do it.
-
so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?
To err is human to really elephant it up you need a computer