• (cs)

    Sweet.  People never cease to amaze me, daily, on this website.

  • (cs)

    Not a terribly bad WTF by any stretch.  I would guess that at sometime some analyst. wrote a spec and the one of the pieces was written to comply with that spec.  Then they realized the spec was wrong and it was easier to modified the other piece to fix it.

    Yes, it is odd, but probably not worth the trouble of fixing.

  • Lenny (unregistered) in reply to RevMike

    The "trouble of fixing" involves deleting a "- 1" and a "+ 1".  Come on, how lazy have we become?

  • Lenny (unregistered) in reply to Lenny

    Acutally, some might prefer adding a "+ 1" and a "-1" instead.  [:D]

    SET @sequenceNum = @@IDENTITY - 1 + 1

    intNewCaseSequenceNum = rsCaseNum("CaseSequenceNum") + 1 - 1

  • (cs) in reply to Lenny
    Anonymous:
    The "trouble of fixing" involves deleting a "- 1" and a "+ 1".  Come on, how lazy have we become?


    That depends on where you are working.  For many of my clients it means getting a QA resource.  Creating and agreeing upon a QA plan.  Implementing that plan.  Getting sign-offs from the user representatives.  Scheduling a release.  Writing a release plan.  Validating the release plan against the integration testing system.  And finally deploying.

    Deploying a change like this can easily take 40 man hours spread amongst several groups.  No one bothers with this crap except that someone probably has it in the back of their mind that if they ever go into this section of code for another reason, they'll clean this up while they're doing it.
  • OneMHz (unregistered) in reply to RevMike

    Agreed it can be a pain to implement a change halfway through, but it was stated that these were developed at the same time.  So if both were part of the same QA/release cycle, I don't see how removing a -1 from a stored proc would add to said QA/release cycle.

  • (cs) in reply to RevMike

    Crap like that is created for many reasons.  In CMM organizations in Level 2 and 3 (what I like to call the Authoritarian and Totalitarian states), typically you find a sore spot in the I/T architecture such as a flaky database, so the powers that be give the "NO STORED PROC/SCHEMA CHANGES UNLESS YOU GO THROUGH PROCESS X".

    Later on, a developer on a project in the peripheray needs a tweak to some stored procs or discovers something wrong inside the highly managed environment.  Since the programmer is a peon and has more control over the local project but the highly managed environment has a committe (or worse, it's highly politicized and making changes will create conflict between departments), it's just easier to avoid PROCESS X and just slap that extra bit of code so you can move along.

    After all, you're getting paid solely to code jokey on Program Foo and you will be judged on how fast you get Program Foo done, not to be a Project Manager for some "superduper" enterprise system and make corrections to other peoples' mistakes.

  • (cs) in reply to RevMike

    RevMike:
    Anonymous:
    The "trouble of fixing" involves deleting a "- 1" and a "+ 1".  Come on, how lazy have we become?


    That depends on where you are working.  For many of my clients it means getting a QA resource.  Creating and agreeing upon a QA plan.  Implementing that plan.  Getting sign-offs from the user representatives.  Scheduling a release.  Writing a release plan.  Validating the release plan against the integration testing system.  And finally deploying.

    Deploying a change like this can easily take 40 man hours spread amongst several groups.  No one bothers with this crap except that someone probably has it in the back of their mind that if they ever go into this section of code for another reason, they'll clean this up while they're doing it.

    Dude, if you have that big of a fiasco for such a simple change, than management needs to take a step back.  Personally, I would roll that as part of another change and put it into that QA/Release cycle, rather than having the +1/-1 released on its own.

    Or I would just change it in the source code, not tell anyone and let the chips fall where they may.  :)

  • (cs) in reply to OneMHz
    Anonymous:
    Agreed it can be a pain to implement a change halfway through, but it was stated that these were developed at the same time.  So if both were part of the same QA/release cycle, I don't see how removing a -1 from a stored proc would add to said QA/release cycle.


    Even as part of the same cycle, changing the stored proc probably means involving a DBA who has 10,000 more important things to do.  Or it may involve coordinating the release of two different pieces of code when the deployment could have been uncoordinated.  Or even the project was in triage and no one wanted to add yet another piece to the puzzle no matter how trivial.

    Because both bits are commented appropriately, I still think that something was written to a bad spec.  They couldn't change it because then it wouldn't comply to the spec.  The process to change the spec was too onerous.  So it went in as-is and simply isn't worth changing.


  • Unknown (unregistered)

    <FONT face=Arial>If we're talking about SQL Server 2000 then using <FONT face="Courier New">@@Identity</FONT> instead of <FONT face="Courier New">Scope_Identity( )</FONT> is a wtf waiting to happen.</FONT>

  • (cs) in reply to fregas
    fregas:

    RevMike:
    Anonymous:
    The "trouble of fixing" involves deleting a "- 1" and a "+ 1".  Come on, how lazy have we become?


    That depends on where you are working.  For many of my clients it means getting a QA resource.  Creating and agreeing upon a QA plan.  Implementing that plan.  Getting sign-offs from the user representatives.  Scheduling a release.  Writing a release plan.  Validating the release plan against the integration testing system.  And finally deploying.

    Deploying a change like this can easily take 40 man hours spread amongst several groups.  No one bothers with this crap except that someone probably has it in the back of their mind that if they ever go into this section of code for another reason, they'll clean this up while they're doing it.

    Dude, if you have that big of a fiasco for such a simple change, than management needs to take a step back.  Personally, I would roll that as part of another change and put it into that QA/Release cycle, rather than having the +1/-1 released on its own.

    Or I would just change it in the source code, not tell anyone and let the chips fall where they may.  :)



    Take a step back?  Depends on the environment.  I'm doing a lot of work with three of the world's top five investment banking houses.  The practices that are appropriate to managing the web site for your local dry cleaner don't cut it when hundreds of billions of dollars are on the line.  Code doesn't go into production that doesn't have a verifiable audit trail.

    If just the risks of losing money wasn't enough motivation, SarbOx has made the CTO/CIO criminally liable for these systems.  In other words, if the CIO fails to take reasonable steps to secure his systems against both incompetence and malice, and that damages the clients of that firm, he can be arrested, convicted, and imprisoned.

    The process that surrounds a system needs to be proportional to the potential damage that the failure of that system will cause.
  • (cs)

    Correct me if I'm wrong (and I openly admit that I probably am), but if the stored procedure and the component code call each other, doesn't this set up infinte recursion??  Or am I misinterpreting the "Both exclusively call each other" statement?

  • Godeke (unregistered) in reply to fregas

    The chips may fall on your termination. Yes, the code does and then undoes something that seems easy to fix. Back in my cowboy coder days I would have fixed it in a  heartbeat. But, I have learned the hard way that sometimes the simple stuff has the deepest implications. Perhaps the stored procedure does what it does to conform to some other portion of the system or to some other system entirely. Removing the +1 and -1 is a noop for your situation, but what about the poor guy down the hall working on a different program that uses the same prodedure as depends on the action of that procedure to be as described? In a large organization cowboy coding of that nature can be very nasty.

  • Disgruntled DBA (unregistered)

    Why?  WHY?!  Why is he returning the value as a recordset AND an output parameter?  WHY, GOD?!

  • (cs) in reply to kipthegreat
    kipthegreat:
    Correct me if I'm wrong (and I openly admit that I probably am), but if the stored procedure and the component code call each other, doesn't this set up infinte recursion??  Or am I misinterpreting the "Both exclusively call each other" statement?


    The language was indeed confusing,  As far as the submitter knows, the COM object calls only this stored procedure, and this stored procedure is only called by the COM object.
  • (cs) in reply to Disgruntled DBA
    Anonymous:
    Why?  WHY?!  Why is he returning the value as a recordset AND an output parameter?  WHY, GOD?!


    A recordset, an output parameter, and the return code too.

    Guess he felt guilty and took out the PRINT statement.
  • (cs) in reply to Disgruntled DBA
    Anonymous:
    Why?  WHY?!  Why is he returning the value as a recordset AND an output parameter?  WHY, GOD?!


    Some development environments prefer to deal with recordsets from databases, while others can comfortably work with scalars.  He wanted to leave that paradigm choice up to any future caller.

    Or, more likely, because it was his first time writing in T-Sql, he had a few fragments of example code, and kept trying things until it worked.  This is the same methodology that I use with VB.  I write java, perl, C, and PL/SQL.  I tune SQL.  I've designed good relational schemas.  I've architected effective J2EE.  Plus I grok regex better than 95%.  If I actually learned VB, it would make me stupider, and I wouldn't be able to do my job.
  • (cs) in reply to RevMike

    RevMike:

    The process that surrounds a system needs to be proportional to the potential damage that the failure of that system will cause.

     

    well said....

     

    (what

  • (cs) in reply to RevMike

    RevMike:

    The process that surrounds a system needs to be proportional to the potential damage that the failure of that system will cause.

    well said....

  • (cs)

    <font>-- COM method increments the value passed back
    </font>
    'procedure decrements the new case num

    Obviously written by a developer with dissociative identity disorder.


  • (cs) in reply to RevMike
    RevMike:
    I write java, perl, C, and PL/SQL.  I tune SQL.  I've designed good relational schemas.  I've architected effective J2EE.  Plus I grok regex better than 95%.


    I invented my own programming language with a keyword that executes a loop exactly 65565 times.  I killed a bear with my bare hands.  I part my hair on the right.  My penis is made of solid gold and tastes like cotton candy.  I have turned down more jobs than you will ever be offered.  My laptop is so advanced they won't let me take it on airplanes.  I wear a Hawaiian shirt to work.  I drive a Dodge Stratus.  Big time stuff.
  • (cs) in reply to kipthegreat
    kipthegreat:
    RevMike:
    I write java, perl, C, and PL/SQL.  I tune SQL.  I've designed good relational schemas.  I've architected effective J2EE.  Plus I grok regex better than 95%.


    I invented my own programming language with a keyword that executes a loop exactly 65565 times.  I killed a bear with my bare hands.  I part my hair on the right.  My penis is made of solid gold and tastes like cotton candy.  I have turned down more jobs than you will ever be offered.  My laptop is so advanced they won't let me take it on airplanes.  I wear a Hawaiian shirt to work.  I drive a Dodge Stratus.  Big time stuff.


    Well, if you want to go there...

    My penis is made of diamond.  I have no hair.  I wrestle 14 foot alligators for fun.  I make more money in one day than you will in your entire career.  I go to work in a silk robe.  I drive a Saturn station wagon.  I scoff at your idea of big time.
  • travis (unregistered) in reply to RevMike

    Lets take a poll.  Whose e-penis is bigger?  RevMike? Or kipthegreat?  

  • (cs) in reply to RevMike

    Wow, a geeky version of "my thingy's bigger than your thingy"

    Just a point, but if they "exclusively call each other" then how do either of them ever get called? (And yes, I realise that this is why there was the chicken-and-egg reference in there).

  • (cs) in reply to johnl

    And why for the love of God is he incrementing something then decrementing it then incr- why, why, why?

    (Or have I completely misunderstood what's happening?)

  • Anonymous man! (unregistered) in reply to fregas
    fregas:

    Dude, if you have that big of a fiasco for such a simple change, than management needs to take a step back. 

    Have you ever seen a large insurance company's process?  Or a government's process?  Don't even think of breathing without change control.  It's irritating that to fix a spelling error that it has to go through three environments and testing...

  • (cs) in reply to RevMike
    RevMike:

    ...
    If just the risks of losing money wasn't enough motivation, SarbOx has made the CTO/CIO criminally liable for these systems.  In other words, if the CIO fails to take reasonable steps to secure his systems against both incompetence and malice, and that damages the clients of that firm, he can be arrested, convicted, and imprisoned.
    ...

    Hmmm!   From yesterday's wtf, the above doesn't apply to the Dexia bank in Brussels. (7777).

  • (cs) in reply to RevMike

    RevMike:
    Plus I grok regex better than 95%.

    <FONT face="Courier New" size=2>what the hell does that mean?  you either grok something or you don't.</FONT>

    RevMike:
    If I actually learned VB, it would make me stupider, and I wouldn't be able to do my job.

    <FONT face="Courier New" size=2>yes, this is true.  then again, you also mentioned you write perl.</FONT>

  • (cs) in reply to triso
    triso:
    RevMike:

    ...
    If just the risks of losing money wasn't enough motivation, SarbOx has made the CTO/CIO criminally liable for these systems.  In other words, if the CIO fails to take reasonable steps to secure his systems against both incompetence and malice, and that damages the clients of that firm, he can be arrested, convicted, and imprisoned.
    ...

    Hmmm!   From yesterday's wtf, the above doesn't apply to the Dexia bank in Brussels. (7777).



    The US congress can't make laws that apply to Europe... yet.

    On a more serious note, in general the burden with these kinds of laws is to prove that the management didn't take reasonable steps.  If the management was taking reasonable steps and something still slipped through that wouldn't trigger legal action.

    For instance, if the CIO was to say "We trusted our QA team." he might still be vulnerable.  However, if he could say "We trusted our QA team because we regularly audit their performance and found them to be reliable in the past." he would probably be fine.
  • (cs) in reply to emptyset
    emptyset:

    RevMike:
    Plus I grok regex better than 95%.

    <font face="Courier New" size="2">what the hell does that mean?  you either grok something or you don't.
    </font>


    I mean that I know more about regex than 95% of the developer community.

    emptyset:

    RevMike:
    If I actually learned VB, it would make me stupider, and I wouldn't be able to do my job.

    <font face="Courier New" size="2">yes, this is true.  then again, you also mentioned you write perl.</font>



    The key to knowing perl is to know when not to use it.  I write a fair amount of glue code - shell script type tasks with it, as well as one-off utilities.  I use it for rapid prototyping.  I don't use it for application development because it rapidly becomes unmaintainable.
  • (cs) in reply to RevMike

    RevMike:
    I mean that I know more about regex than 95% of the developer community.

    <FONT face="Courier New" size=2>cool!  maybe you can convince some of the non-believers that regexes can detect substrings in O(1).</FONT>

  • WhatTheFred (unregistered) in reply to emptyset
    emptyset:

    RevMike:
    I mean that I know more about regex than 95% of the developer community.

    <font face="Courier New" size="2">cool!  maybe you can convince some of the non-believers that regexes can detect substrings in O(1).</font>


    O(1)?  Dude, can I have a copy of your magic pixie-dust quantum regex library?  Pretty please?
  • (cs) in reply to WhatTheFred

    Anonymous:
    O(1)?  Dude, can I have a copy of your magic pixie-dust quantum regex library?  Pretty please?

    <FONT face="Courier New" size=2>it's what perl uses.  that's why so many people use perl:  because regexes are faster than looping/parsing through a string.  the regexes use 'caching' to quickly detect if a substring is present in a string by polling a constant number of characters.</FONT>

  • Sceptic (unregistered) in reply to emptyset

    Regexes can detect substrings in O(1)? This is an argument I need to see.

    My first thought is that, at a minimum, the entire string to search must be examined, otherwise matches in various parts of the string could be missed. Admittedly, for short strings, this may APPEAR to be linear, but if you're applying a regex to, say, a 4gb flat file, you might discover that it's more of the order O(n), where n is the size of the string to search. This is, of course, ignoring the potential size of the substring, which would add complexity.

    I'm not saying that you can't make a good argument for O(1), merely that I'm quite sceptical.

  • seebs (unregistered)

    It looks to me like the database code decrements a value and stores it in the database, while the calling procedure wants the undecremented value.  So this is just an elaborate way of writing a postdecrement, no?

  • Sceptic (unregistered) in reply to emptyset

    A constant number of characters? The same number of characters to search a 100 char string as a 4gb flat file?

    I call BS.

  • Frost (unregistered) in reply to emptyset
    emptyset:

    Anonymous:
    O(1)?  Dude, can I have a copy of your magic pixie-dust quantum regex library?  Pretty please?

    <FONT face="Courier New" size=2>it's what perl uses.  that's why so many people use perl:  because regexes are faster than looping/parsing through a string.  the regexes use 'caching' to quickly detect if a substring is present in a string by polling a constant number of characters.</FONT>

     

    Perhaps you don't understand what O(1) means?  You are saying that a regex scans a 10-character string in the same amount of time as it scans a million-character string.

  • Jibbity (unregistered) in reply to Frost

    I'm smelling copious amounts of sarcasm here.

  • (cs) in reply to RevMike

    RevMike:

    Deploying a change like this can easily take 40 man hours spread amongst several groups.  No one bothers with this crap except that someone probably has it in the back of their mind that if they ever go into this section of code for another reason, they'll clean this up while they're doing it.

    I've been in a place like that. What I'd do is when I get a real project (add a feature), I would spend at least a week refactoring old code before I even start coding the new feature. After that I will finish developing the feature and release the software. I would produce a big technical description document, of course no one would read this, but at least I documented everything I did. It did feel funny to write "rewrote the back-end page engine" as one of the modifications done in the "add a new web page" project, but at least I was sure they were better off with the refactored code than with the old POS. And they expected to go through a release cycle anyway.   

  • (cs) in reply to fregas
    fregas:

    Or I would just change it in the source code, not tell anyone and let the chips fall where they may.  :)

    Can you say source control?  Can you say SOx audit violation?

  • (cs) in reply to kipthegreat

    kipthegreat:
    RevMike:
    I write java, perl, C, and PL/SQL.  I tune SQL.  I've designed good relational schemas.  I've architected effective J2EE.  Plus I grok regex better than 95%.


    My penis is made of solid gold and tastes like cotton candy.

    But...does it still have feeling?

  • (cs) in reply to Frost
    Anonymous:
    emptyset:

    Anonymous:
    O(1)?  Dude, can I have a copy of your magic pixie-dust quantum regex library?  Pretty please?

    <font face="Courier New" size="2">it's what perl uses.  that's why so many people use perl:  because regexes are faster than looping/parsing through a string.  the regexes use 'caching' to quickly detect if a substring is present in a string by polling a constant number of characters.</font>

     

    Perhaps you don't understand what O(1) means?  You are saying that a regex scans a 10-character string in the same amount of time as it scans a million-character string.



    Dude, even better: in Perl, a regex can scan a 10-character string in even less time than it can a million-character string. :-)
  • (cs) in reply to emptyset
    emptyset:

    Anonymous:
    O(1)?  Dude, can I have a copy of your magic pixie-dust quantum regex library?  Pretty please?

    <FONT face="Courier New" size=2>it's what perl uses.  that's why so many people use perl:  because regexes are faster than looping/parsing through a string.  the regexes use 'caching' to quickly detect if a substring is present in a string by polling a constant number of characters.</FONT>

    emptyset:

    Anonymous:
    O(1)?  Dude, can I have a copy of your magic pixie-dust quantum regex library?  Pretty please?

    <FONT face="Courier New" size=2>it's what perl uses.  that's why so many people use perl:  because regexes are faster than looping/parsing through a string.  the regexes use 'caching' to quickly detect if a substring is present in a string by polling a constant number of characters.</FONT>

    The naïve search algorithm (as expressed here in Python):

        def myfind(haystack, needle):
            for i in range(len(haystack)):
                if haystack.startswith(needle, i):
                    return True
            return False
    

    uses O(n*h) time with n = the length of the needle and h = the length of the haystack. It uses O(n+h) space, since both have to be stored until finished.

    The regular expression version is indeed more efficient, but not O(1). It assembles a DFA (deterministic finite automata) based on the needle, using...umm, I think O(n) space...certainly polynomial with respect to the needle. It has some preparatory work to do that's also polynomial with respect to the needle; this part can be reused for any number of searches with the same needle. (Compile your regular expressions once at the module level!) The actual search is O(h).

  • (cs) in reply to RevMike
    RevMike:

    The process that surrounds a system needs to be proportional to the potential damage that the failure of that system will cause.


    I hope you're not actually advocating that kind of policy. Imagine this:

    "Central here.... Yes.... There's a fire? Sure, we'll dispach a firemen crew ASAP, but first we need you to file a Fire Control Form in triplicate to... No, sir, I'm afraid we can't skip this step.... I'll fax the form to you right... Oh, your fax machine has melted? Ok, I'll mail it to you, what was the address again?..... Sir?...... Sir?!......."

    Oh man, when are we going to learn to just DO THE RIGHT THING?

  • Krenn (unregistered)

    The problem with "just changing it" is that you're making an assumption that these are both called ONLY by each other.

    If there's some second COM that does not increment, then removing the -1 from the stored proc will break it.

    Apologies if that was mentioned already, a brief skim through didn't show it.

  • (cs) in reply to Krenn
    Anonymous:
    The problem with "just changing it" is that you're making an assumption that these are both called ONLY by each other.

    If there's some second COM that does not increment, then removing the -1 from the stored proc will break it.

    Apologies if that was mentioned already, a brief skim through didn't show it.


    It was mentioned, but it didn't get the proper answer.

    What do you think source control and unit testing are good for?

  • (cs) in reply to felix

    felix:
    RevMike:

    The process that surrounds a system needs to be proportional to the potential damage that the failure of that system will cause.


    I hope you're not actually advocating that kind of policy. Imagine this:

    "Central here.... Yes.... There's a fire? Sure, we'll dispach a firemen crew ASAP, but first we need you to file a Fire Control Form in triplicate to... No, sir, I'm afraid we can't skip this step.... I'll fax the form to you right... Oh, your fax machine has melted? Ok, I'll mail it to you, what was the address again?..... Sir?...... Sir?!......."

    Oh man, when are we going to learn to just DO THE RIGHT THING?

    Bravo! Excellent choice of taking a twisted view when comparing two totally different scenarios! In emergency central the process of course involves rapid actions as doing things quickly is more important than doing them absolutely foolproof every single time. I think emergency central's process would be quite different if cost of failure would be a thousand lives instead of one or two...

  • Anonymouse (unregistered) in reply to Magic Duck

    Did you consider that the stored procedure might be called by more than just this one application?

    This is also the problem of using logic in stored procedures, you start to spread the logic of the applications around so solving problems can be a bit of a search.

    Stored procedures are nice for their performance, but horrible for a clean architecture with a clearly defined business-logic layer.

  • Porsche3000 (unregistered) in reply to RevMike

    RevMike:
    Anonymous:
    Why?  WHY?!  Why is he returning the value as a recordset AND an output parameter?  WHY, GOD?!


    Some development environments prefer to deal with recordsets from databases, while others can comfortably work with scalars.  He wanted to leave that paradigm choice up to any future caller.

    Or, more likely, because it was his first time writing in T-Sql, he had a few fragments of example code, and kept trying things until it worked.  This is the same methodology that I use with VB.  I write java, perl, C, and PL/SQL.  I tune SQL.  I've designed good relational schemas.  I've architected effective J2EE.  Plus I grok regex better than 95%.  If I actually learned VB, it would make me stupider, and I wouldn't be able to do my job.

    I work with VB and earn 6 figures. 

     

  • (cs) in reply to kipthegreat
    kipthegreat:

    I invented my own programming language with a keyword that executes a loop exactly 65565 times.  I killed a bear with my bare hands.  I part my hair on the right.  My penis is made of solid gold and tastes like cotton candy.  I have turned down more jobs than you will ever be offered.  My laptop is so advanced they won't let me take it on airplanes.  I wear a Hawaiian shirt to work.  I drive a Dodge Stratus.  Big time stuff.


    Wow. All of that, and you go and ruin it with a Dodge Stratus.[:'(]

Leave a comment on “Working Around Yourself”

Log In or post as a guest

Replying to comment #:

« Return to Article