• (cs) in reply to Your Name
    Your Name:
    rogueuser:
    I hate single letter varibles! Everytime I have to search code for a varible named 'a' I want to scream!

    Use "vi", then /<a>/ finds just that variable, and not the "a" in assert or whatever

    Nice, Thanks! I sux I forgot the a in variable twice

  • Joseph Newton (unregistered) in reply to rp
    rp:
    Jonh Robo:
    ...but if you lose:

    If Session("Reprint") = "" Then Session("Reprint") = "" End If

    then how will Session("Reprint") ever get set to "" if Session("Reprint") is equal to ""?

    I'm not quite sure whether you're serious, but I hope you are.

    The trouble with refactoring is the hidden landmines (i.e. people don't document the invariants their code relies on). In this case, a string can compare equal to "" without actually being the same as "", for instance, when it's a null reference (Nothing in VB.NET), and then be passed to a piece of code that depends on such strings actually being the same as "". ...

    Sounds to me like you make an excellent case for refactoring. Why place bandages on a kludge? You just end up with a mass of incomprehensible, half-dead, bandaged code that way. If a function is so long that you can't remember the type assigned to a variable when you use it, then it is time to break that function down into more comprehensible chunks. If time-bombs are scattered throughout an application, then it's time to refactor the program to root them out.

  • htg (unregistered) in reply to Your Name
    Your Name:
    rogueuser:
    I hate single letter varibles! Everytime I have to search code for a varible named 'a' I want to scream!

    Use "vi", then /<a>/ finds just that variable, and not the "a" in assert or whatever

    Use Eclipse or any decent IDE. Select variable. This highlights all instances of the variable in the file. Then selected Refactor. Enter sensible variable name.

    Two birds killed with a very large boulder. Asteroid. Planetoid. With one hand on the mouse instead of on the keyboard. Bum.

    Dammit, why don't you make the damn captcha antidisestablishmentarianism if it's going to be so long?

  • (cs) in reply to rogueuser
    rogueuser:
    Your Name:
    rogueuser:
    I hate single letter varibles! Everytime I have to search code for a varible named 'a' I want to scream!
    Use "vi", then /\<a\>/ finds just that variable, and not the "a" in assert or whatever
    Nice, Thanks! I sux I forgot the a in variable twice
    Hey, I thought it was a joke (searching for the letter a not within words.)
  • (cs) in reply to htg
    htg:
    ... Dammit, why don't you make the damn captcha antidisestablishmentarianism if it's going to be so long?
    Captcha disappears if you register.
  • dolo54 (unregistered)
    <quote> If Session("Reprint") = "" Then Session("Reprint") = "" End If </quote>

    seriously that is blowing my mind! it's like the programmer said to himself "time to go monk. cacawww cacawww"

  • (cs) in reply to drd
    drd:
    Even easier, (assuming by 'vi' you mean 'vim'), just move your cursor to the 'a' token, then type *. You'll get the word-boundary restrictions automatically.
    You can also do it in Emacs. Simply turn your keyboard upside down and smash it onto your desk, thus depressing all keys at once. This is the approved method of accomplishing anything in Emacs.
  • Reed (unregistered) in reply to Aaron
    Aaron:
    The fact that a good majority of the "code WTFs" are in VB doesn't help my opinion that VB is an inferior language. :P

    That's a population error. There's simply great gobs of VB code out there, especially for random in-house programs businesses make for themselves and don't care that much about the maintainability of.

  • ncloud (unregistered)

    Props for the Objectivist reference:

    If Session("Reprint") = "" Then Session("Reprint") = "" End If

    remember... A is A :-)

  • mo (unregistered)

    all my perl scripts look like this. I use it at most once a month so it takes me a few hundred lines to remember all the bug--I mean how Larry Wall thinks.

  • J. B. Rainsberger (unregistered) in reply to KattMan
    To a manager, refactor means to upgrade or add functionality. It is a danger of us techies using our language to explain something to non-techies.

    When the hell did this happen? I would love to know the etymology of this use of "refactor".

    This isn't a danger of "our language vs. theirs", it's a danger of using a word to mean something it can't possibly mean.

  • Duncan Bayne (unregistered)

    I wonder then if that means that we Objectivists should spurn nullable types? ;-)

  • Bill (unregistered)

    What a dumbass.

  • EnviroWeenie (unregistered)

    With NetBeans, I can easily rename variables, procedures and classes. The upcoming NB 6 will allow even deeper forms of refactoring, that make structural changes to the way a method or class is used, not just the name.

  • Watson (unregistered) in reply to bstorer
    bstorer:
    KattMan:
    Things just get hairy when you don't have a good escaping format.
    The key is to keep the XSLT from transforming the escaped characters on every pass, say through using CDATA. More specifically, through the cdata-section-element attribute of the xsl:output element. I'd provide a complete example, but I don't work in XSLT unless I'm getting paid to do so.

    Which reminds me; how do you escape "]]>" so that it can appear in CDATA? Please tell me it's not ]]]]><[CDATA[>. Please. Even if it is. Because what if I want ]]]><[CDATA[>? ]]]]]><[CDATA[><[CDATA[>?

  • Anonymous (unregistered) in reply to KattMan
    KattMan:
    JGM:
    But if you allow ,, to escape , how do you specify an empty column?

    Well true. But you should have one escaping character and use it everywhere even when escaping itself. I admit my example was off the mark but it does show part of the problems with not defining an escaping character. There are other formats that come to mind, VB and SQL handling things in a similar fashion while C uses \ and \ to escape the escape character.

    Then XML comes to mind where there is no easy way to place a & in a field that needs to be parsed by XSL then used in the resulting HTML. For example you want to have a non-breaking space so the final HTML needs to show   but the XSL transform will escape it out to a space on it's own leaving you with literally a blank that might not get rendered so you have to encode this in the original XML as such: &nbsp;. This means you have to know how many transforms you are going to go through from the begining before you can encode it properly. Got another level to transform through, then you need to encode it as such: &amp;nbsp;

    Things just get hairy when you don't have a good escaping format.

    Doesn't   [1] or xls:text </xls:text> [2] work?

    [1] http://www.biglist.com/lists/xsl-list/archives/200207/msg01137.html)

    [2] http://lists.evolt.org/archive/Week-of-Mon-20010500/031481.html

  • (cs) in reply to rp
    rp:
    Jonh Robo:
    A Refactoring Conundrum

    ...but if you lose:

    If Session("Reprint") = "" Then Session("Reprint") = "" End If

    then how will Session("Reprint") ever get set to "" if Session("Reprint") is equal to ""?

    I'm not quite sure whether you're serious, but I hope you are.

    The trouble with refactoring is the hidden landmines (i.e. people don't document the invariants their code relies on). In this case, a string can compare equal to "" without actually being the same as "", for instance, when it's a null reference (Nothing in VB.NET), and then be passed to a piece of code that depends on such strings actually being the same as "". Try this at home:

    <blah/>
    

    Except we aren't talking .NET, but VBScript where every variable is a Variant. Passing Nothing in a strongly typed language to a method expecting a String will get you a Nothing of type String. Passing Nothing to a VBScript method "expecting" a string will get you a Nothing of type Variant. Nothing does NOT equal "" just as it doesn't equal Null, Empty, 0, False or FILE_NOT_FOUND.

  • woohoo (unregistered) in reply to rogueuser
    rogueuser:
    I hate single letter varibles! Everytime I have to search code for a varible named 'a' I want to scream!

    I do hope that you search for " a " (with blanks before/after) or better "\s*a\s+" or similar (at least in editors supporting regexes...) in such cases, not for "a" ... ;o)

  • (cs) in reply to Watson
    Watson:
    bstorer:
    KattMan:
    Things just get hairy when you don't have a good escaping format.
    The key is to keep the XSLT from transforming the escaped characters on every pass, say through using CDATA. More specifically, through the cdata-section-element attribute of the xsl:output element. I'd provide a complete example, but I don't work in XSLT unless I'm getting paid to do so.

    Which reminds me; how do you escape "]]>" so that it can appear in CDATA? Please tell me it's not ]]]]><[CDATA[>. Please. Even if it is. Because what if I want ]]]><[CDATA[>? ]]]]]><[CDATA[><[CDATA[>?

    You can't put "]]>" in CDATA. The simplest way is to do what you dread: "]]]]><[CDATA[>". However, perhaps you'd prefer "]]]]>>"? You'll always have problems with escaping characters, thanks to that lousy pigeon hole principle. Life would be so much better without that...
  • woohoo (unregistered) in reply to Massif
    Massif:
    Is that where two-letter commands come from? Are well-named variables several generations down?

    The evolution of variable names (I tried to come up with something simple, "locus variabilis" meaning literally "variable place", I'm not sure if there's an official translation for "(memory) variable" into latin ;o) "pernimius" means "way too big")

    a: locus variabilis stupidus

    an: loc. var. neanderthalensis

    accNo: loc. var. sapiens

    accountNumber: loc. var. sapiens sapiens

    accountNumberForBankingAccountInBankingApplication: loc. var. pernimius insanus

  • Stan (unregistered)

    Nobody minds that a function called CheckString doesn't check a string? And I love vlu. If your naming standard is to remove all the vowels it should be vl.

  • (cs) in reply to woohoo
    woohoo:
    Massif:
    Is that where two-letter commands come from? Are well-named variables several generations down?

    The evolution of variable names (I tried to come up with something simple, "locus variabilis" meaning literally "variable place", I'm not sure if there's an official translation for "(memory) variable" into latin ;o) "pernimius" means "way too big")

    a: locus variabilis stupidus

    an: loc. var. neanderthalensis

    accNo: loc. var. sapiens

    accountNumber: loc. var. sapiens sapiens

    accountNumberForBankingAccountInBankingApplication: loc. var. pernimius insanus

    Demonstrating admirably why controlling of the mating process and evolutionary systems should be tightly controlled by qualified specialists.

  • (cs) in reply to woohoo
    woohoo:
    Massif:
    Is that where two-letter commands come from? Are well-named variables several generations down?

    The evolution of variable names (I tried to come up with something simple, "locus variabilis" meaning literally "variable place", I'm not sure if there's an official translation for "(memory) variable" into latin ;o) "pernimius" means "way too big")

    a: locus variabilis stupidus

    an: loc. var. neanderthalensis

    accNo: loc. var. sapiens

    accountNumber: loc. var. sapiens sapiens

    accountNumberForBankingAccountInBankingApplication: loc. var. pernimius insanus

    I think what you want is the supine, or gerundal, form of an appropriate verb.

    May I suggest "mutandum," or "that which is to be changed?" The equivalent for a constant would be, unsurprisingly, "constatum," or "that which is fixed/agreed upon."

  • woohoo (unregistered) in reply to real_aardvark
    real_aardvark:
    woohoo:
    Massif:
    Is that where two-letter commands come from? Are well-named variables several generations down?

    The evolution of variable names (I tried to come up with something simple, "locus variabilis" meaning literally "variable place", I'm not sure if there's an official translation for "(memory) variable" into latin ;o) "pernimius" means "way too big")

    a: locus variabilis stupidus

    an: loc. var. neanderthalensis

    accNo: loc. var. sapiens

    accountNumber: loc. var. sapiens sapiens

    accountNumberForBankingAccountInBankingApplication: loc. var. pernimius insanus

    I think what you want is the supine, or gerundal, form of an appropriate verb.

    May I suggest "mutandum," or "that which is to be changed?" The equivalent for a constant would be, unsurprisingly, "constatum," or "that which is fixed/agreed upon."

    Basically you have a point, but I wanted to keep it simple (how many people do know what a gerund is? ;o) and the simple version "changing place" (as opposed to "place to be changed") maybe even catches the intent of a variable more appropriately... didn't want to dive into a linguistic discussion, though ;o)

  • (cs) in reply to woohoo
    woohoo:
    real_aardvark:
    I think what you want is the supine, or gerundal, form of an appropriate verb.

    May I suggest "mutandum," or "that which is to be changed?" The equivalent for a constant would be, unsurprisingly, "constatum," or "that which is fixed/agreed upon."

    Basically you have a point, but I wanted to keep it simple (how many people do know what a gerund is? ;o) and the simple version "changing place" (as opposed to "place to be changed") maybe even catches the intent of a variable more appropriately... didn't want to dive into a linguistic discussion, though ;o)

    No, sorry about that -- it did rather kill the spirit of the thing.

    However, it's interesting to note that the terms we (programmers) use are actually closer to gerundives than to gerunds ("variable" and "constant" being essentially adjectival forms of the verb). This would make Ancient Greek a more appropriate language for programming than Latin.

    But I'm sure we don't want to go there...

    However, since you bind variables to a value, I would still stand by that old supine favourite. Well, that or S&M.

  • woohoo (unregistered) in reply to real_aardvark
    real_aardvark:
    woohoo:
    real_aardvark:
    I think what you want is the supine, or gerundal, form of an appropriate verb.

    May I suggest "mutandum," or "that which is to be changed?" The equivalent for a constant would be, unsurprisingly, "constatum," or "that which is fixed/agreed upon."

    Basically you have a point, but I wanted to keep it simple (how many people do know what a gerund is? ;o) and the simple version "changing place" (as opposed to "place to be changed") maybe even catches the intent of a variable more appropriately... didn't want to dive into a linguistic discussion, though ;o)

    No, sorry about that -- it did rather kill the spirit of the thing.

    However, it's interesting to note that the terms we (programmers) use are actually closer to gerundives than to gerunds ("variable" and "constant" being essentially adjectival forms of the verb). This would make Ancient Greek a more appropriate language for programming than Latin.

    But I'm sure we don't want to go there...

    However, since you bind variables to a value, I would still stand by that old supine favourite. Well, that or S&M.

    absolutely no reason to apologize :o) I concur that adjectival forms are better suited than gerunds.

    the supine that you'd prefer ("mutandum" or also "variabilium" if I didn't get the ending wrong) would translate as "to change", but if I remember correctly, supines demand a verb of motion (like "going" etc.) and can't just stand on their own, very much the same as in english really - it just looks like a plain infinitive when lurking around alone. correct me if I'm wrong...

    I'd rather stick to "variabilis" or "mutabilis" and translate it as "changeable" (not "changing", as I did in my answer to your post slap ;o), which to me seems to be closest to the spirit of what variables are.

    hey, don't tell me that you learned ancient greek in school? I did, but it's a crying shame how much I've already forgotten... the same holds true for latin, but I found greek much more fascinating :o)

  • woohoo (unregistered) in reply to woohoo

    ======= Edit of my own above post =======

    ...the supine that you'd prefer ("mutandum" or...

    erm, sorry... copy&paste... the supine would be "mutatum" ("mutandum" is the gerund...)

  • Zecc (unregistered)

    I must admit, I have done some refactoring myself. I have once changed:

    Warning = IntegerToBoolean(TextToInteger(FormatBoolean(FeedMsg<>"", 1, 0)))

    to:

    Warning = (FeedMsg <> "")

    NB: This is in a 'language' used in a graphical GUI that I am being forced to use for development. FormatBoolean takes a Boolean and two Texts (in this case implicitly converted Integers) and returns one of them as Text. In other words, it acts like the ?: operator in C, except the return value is always Text (which cannot be implicitly converted back to Integer or anything else for that matter).

    And yes, 1 and 0 are converted to Boolean as expected.

  • Nelle (unregistered) in reply to Your Name
    Use "vi", then /\<a\>/ finds just that variable, and not the "a" in assert or whatever

    Type in 8 letters to find one :)

  • Simmo (unregistered)

    'Objectivist'

    Now that's funny.

  • INSERT INTO trashcan (this_code); TRUNCATE TABLE trashcan; (unregistered) in reply to JGM
    JGM:
    But if you allow ,, to escape , how do you specify an empty column?
    , ,

Leave a comment on “Refactoring History”

Log In or post as a guest

Replying to comment #:

« Return to Article