• Kemp (unregistered) in reply to Still coding in C++

    I don't get how so many of you are making identical coding mistakes here. You're doing code roughly as

    - Do a loop to get a value for a variable
    - If certain conditions are met then set variable to a particular value
    - Return variable

    Why do you make it execute the loop?

    - If certain conditions are met then return a particular value
    - Do a loop to get a value for a variable
    - Return variable

     

    captcha is all-knowing as ever : wtf

  • (cs) in reply to Gene Wirchenko

    I had a teacher like that once. He was the only computer teacher in the building, and was piss poor at what he did. It was me and a few of my friends in a programming club, and I was the only one who knew jack about programming. Eventually, the teacher handed me the marker and offered to let me teach the class. I took the marker and proceeded to show my friends what a method was. I talked to them later, and they said that I taught better than the teacher did. They did say that it was a sincere compliment, not just because I was their friend.

  • Konrad (unregistered) in reply to GoatCheez
    GoatCheez:


    Better question would be what DOESN'T support recursion. Recursion isn't a language feature, it's a programming method. If a language has what we all call functions, then you can recurse.
     
    I have encountered languages which support functions but do not allow recusrion. Inorder to suport recursition the compiler and or interpreter needs to be able to hadnle a function being called before it
    has been fully defined. Right now I can;t recall what language it was in but i have encountered interpreted langiuages where calling functions before they are defined is not supported and hence it
    is not possible to do recursion. (I belive but have no evidence that early versions of VB fell into this category)
  • (cs) in reply to Konrad
    Anonymous:
    GoatCheez:
    Better question would be what DOESN'T support recursion. Recursion isn't a language feature, it's a programming method. If a language has what we all call functions, then you can recurse.
     
    I have encountered languages which support functions but do not allow recusrion. Inorder to suport recursition the compiler and or interpreter needs to be able to hadnle a function being called before it
    has been fully defined. Right now I can;t recall what language it was in but i have encountered interpreted langiuages where calling functions before they are defined is not supported and hence it
    is not possible to do recursion. (I belive but have no evidence that early versions of VB fell into this category)


    It is not so much that as not being able to handle a function being called before it is defined.  Without this, you can not have recursive chains (function A which calls function B which calls function A).  Some languages allow declaring the parms separately.

    Once the compiler has the formal parameter list, it has enough information to handle calls, recursive or not (barring a weird language).

    Sincerely,

    Gene Wirchenko

  • Anonymous (unregistered) in reply to Gene Wirchenko

    To get off the "recursion is bad/recursion is good" thread for a second, I have seen (horrible) code like this on a project I worked on. It was a C# front-end that had been written by a back-end (SQL Server) kinda guy, who had no idea what he was doing in UI-land. Because the company had a similar amount of cluefulness they made him do it.

    Basically the entire application was run in the UI thread from the callback code of each of the toolbar buttons!!! But of course he had to allow the same actions to be performed from menu selections as well. So each top-level function in the program began with some similar "is my parent null, or is my parent's *parent* null?" code to work out what context the function was launched from. THEN, depending on the outcome of that, it would set the new UI window's parent to the appropriate container frame. Then the REAL fun began...

    I made a point of grabbing a copy of that app code when I bailed - I should submit it here, there's about a fortnight's worth of code WTF's in there!

  • SoftE (unregistered) in reply to Hartmut

    I find it interesting that everyone is making a lot of assumptions about how this is "supposed" to work when they re-write it.

    Maybe the tree is not allowed to go more than 60 levels deep.  Maybe a circular loop of somekind *is* allowed.  If that's the case, then we've got a lot of people writing infinite loops here.

  • Anonymous (unregistered) in reply to V.

    Perhaps - but the important point is that you can also curse in every language. Not to mention at the language. VB, I'm looking at you....

  • - (unregistered)
  • You Bastard (unregistered) in reply to adwadwawda
    adwadwawda:
    I used to sell my assignments to other CS students.  They'd come up to me, actually crying, because they couldn't understand programming at even the most fundamental level.


    Aha! So it is your damn fault that we have to work with all these hopeless monkeys! I had always wondered how some people had managed to get a degree... until now I guess I had assumed they had made some lewd and nasty arrangements with dirty old professors...

    Grab your torches and pitchforks... let's get him!! :)
  • SLerman (unregistered) in reply to ammoQ
    ammoQ:
    Anonymous:


    10 PRINT "CAN ANCIENT BASIC RECURSE"
    15 REM I THINK YOU COULD ARGUE THIS IS RECURSION WITH NO STACK
    20 GOTO 20


    100 REM RECURSION EXAMPLE
    110 LET L=10
    120 GOSUB 200
    130 PRINT "MOST INEFFICIENT WAY TO SET L TO 0 COMPLETED"
    140 END
    200 LET L=L-1
    210 IF L>0 THEN GOSUB 200
    220 RETURN


    That won't work in all variants of BASIC. I'm not sure about any others, but GWBasic only stored a single return address, no matter how many GOSUB's you have. Basically, you had functions, but you couldn't call another function from within a function and still be able to get back to where you started. I'd say that qualifies for a WTF.
  • Anonymous (unregistered) in reply to GoatCheez

    <font face="Verdana" size="2">Technically, recursion is a language feature. Just because you have functions doesn't mean you can use them recursively. Support for it has to be built in. There are many languages that still don't support recursion to this day, for a variety of reasons (i.e. the ability to inline all functions, etc).

    The more I read comments from the "experts" on this site, the more I think the people who read this site do it so they can see how to improve their coding technique.

    Go read about language design issues, or at the very least stop posting from you ass.

    </font>

  • missing (unregistered) in reply to Bill
    Anonymous:
    Not always. A C compiler I use on a PIC does not allow recursion, or reentrant functions in general. I'd assume this means it is not making use of the stack for any local variables.


    That's because PIC only has a stack 2 or 3 levels deep.  That's what happens when you have well under 1k of RAM.  PIC16F84 has what, 68 bytes?

    Anonymous:
    Relying upon the compiler to do the tail recursion optimization is a bad idea. If optimizations get turned off for any reason, nasty things will start happening.


    Not if you're programming in Scheme.  :)
  • Anonymous (unregistered) in reply to adwadwawda
    Anonymous:
    I used to sell my assignments to other CS students.  They'd come up to me, actually crying, because they couldn't understand programming at even the most fundamental level.
     
    Paid my tuition that way.


    Not that I believe you, but if this was the case then you would lose in the long haul because you have to compete with a bunch of retards that have the same qualifications as yourself, thus lowering your potential earnings and job security.
  • anonymous coward (unregistered) in reply to BizTalk
    Anonymous:
    Anonymous:
    Nobody needs more than 640 KB of RAM^H^H^H^H^H^H^H^H^H^H^H^H^H 60 levels of depth!  (I count 69 not 59 Parents as well)

    And for-loops are for the typing-endurance-challenged.


    lol omg wtf pwned..
     
     you actually counted that shit up dude?

    man get to work slacker jesus christ.

     :)

    woot null captcha!
     
    Well, he could have counted to 17 instead. Its a 7 by 10 rectangle with 1 parent missing. 69. :D



    Grats to Xocomil for being the first to spot that its really one if else with a bunch of unreachable space between (assuming they don't have something weird, like where a node changes when accessed, so you can't know its value and its location at the same time (no, I didn't invent that example, I've seen it done, mostly to torment/test a new programmer in python)   :). 



    And I agree with "you bastard".  Spork adwadwawda!!

  • Omry (unregistered) in reply to JoeBloggs

    I bet it does, it was the next feature after 'on error resume next'.
    but obviously. VB programmers doesn't support recursion.

  • David Taylor (unregistered) in reply to John Hensley

    Take other note: I've had plenty of people work with me or for me with CS degrees and masters (that I didn't hire) whose code was just as bad as that. I'll take my chances talking to someone and asking them questions and listening to the answers rather than looking at worthless pieces of paper when hiring.

    I know some damned good programmers who wanted to get to work rather than go to uni.

  • Chris (unregistered)

    Maybe I've just had a very different experence than the rest of you, but all we did in my first CS course was recursion. My first-year courses went something like this:

    Scheme Lambda Calculus Assembly Java

  • csrster (unregistered) in reply to GoatCheez
    GoatCheez:
    Anonymous:
    Anonymous:

    OMG - when will they start teaching recursion?

    Does Visual Basic even support recursion?



    Better question would be what DOESN'T support recursion. Recursion isn't a language feature, it's a programming method. If a language has what we all call functions, then you can recurse.


    I'm not sure what you call functions :-) but I seem to recall that Fortran 77 did
    not support recursive function calls. Fortran 90 and later does. From what I now know
    about computer science I actually wonder how they built a language which supports
    functions but not recursion. It seems you would have to add extra logic to
    prevent adding an extra stack frame for the same function.

  • Gunther VB (unregistered) in reply to Chris

    Fuck, I didn't know you could get a degree in Counter Strike

    A lot of students graduate that don't know the most basic programming principles, but they do have a *lot* of creativity in solving programming problems in the most unimaginable ways. Some of them aren't even really interested in writing software (and they are the ones that get employed at a company, start writing their enterprisy application from crap, eh scratch, and afterwards we have the joy of maintaining it).

    Plus the whole load of elderly people that write their super duper software in Access and then try finding a professional to maintain and extend it (by sending us letters reading "Skills needed: MS Access, VB Script, blahblah more stuff that isn't relevant).

    Plus all the say.. 28+ year olds that don't even know OO exists, yet they try to mimic it vaguely by using an "ancestor" once in a while.

    I'm in hell.

  • DaddyO(O(h)) (unregistered) in reply to Gunther VB

    Hmmm. What are we talking about here?

    Ahhh ... I see ... Youngsters talking about stuff that's relevant to their generation!

    You haven't figured out that it's all crap after about 1970 yet eh!

    YAWN!

    :-)

    [No harm intended :-)]

  • Erwin (unregistered) in reply to jesuswaffle

    An iterative solution would work just fine here (you get C, because I don't know VB):

    int get_nesting_level(node *n) {
    int i;
    for (i = 0; n; i++)
    n = n->next;
    return i;
    }
     
    Thank heaven for read-only parameters !

  • (cs) in reply to SoftE
    Anonymous:

    I find it interesting that everyone is making a lot of assumptions about how this is "supposed" to work when they re-write it.

    Maybe the tree is not allowed to go more than 60 levels deep.  Maybe a circular loop of somekind *is* allowed.  If that's the case, then we've got a lot of people writing infinite loops here.

    Public Function GetNestingLevel(objNode As Node, maxRecursion as Integer, RecursionLevel as Integer)
        If RecursionLevel < maxRecursion Then
              RecursionLevel = RecursionLevel +1
             <All other Code>
        End If
    End Function

    (I hope the VB-Code is correct, i haven't wrote VB-Code for years)

    No problem with that...

  • Welcor (unregistered) in reply to Gene Wirchenko

    I had one instructor that I put a certain amount of fear into.  When I challenged him on deducting marks because I did not validate a name by checking that it was not numeric, he challenged me to come up with a case of a numeric name.  I came up with two.

    Which were ?

    I mean, I certainly can't come up with any.

  • David (unregistered) in reply to Maxim

    <FONT face=Arial>This looks to me like its the nesting level of a node in a VB6 Treeview control.  So you should be able to do something like this.</FONT>

    <FONT face=Arial>NestingLevel = Ubound(split(objNode.Path,"\")) </FONT>

    <FONT face=Arial>There is a property on the Treeview that tells you the path seperator is but I cant remember it.</FONT>

  • Fred (unregistered) in reply to MikiWatts
    MikiWatts:
    What, only 60 levels? why, back in my days, when we still wrote in white on blue, we went up to 120 levels with char assembly codes and we liked it, yes siree!


    That wouldn't happen to be the same "days" when you also had to go out and collect your own bits, barefoot, in the snow, leaving bloody trails for the wolves to follow?

    Shamelessly copied from Kent Beck, "TDD By Example" ...

  • Pasa (unregistered) in reply to SLerman

    Anonymous:
    ammoQ:
    Anonymous:


    10 PRINT "CAN ANCIENT BASIC RECURSE"
    15 REM I THINK YOU COULD ARGUE THIS IS RECURSION WITH NO STACK
    20 GOTO 20


    100 REM RECURSION EXAMPLE
    110 LET L=10
    120 GOSUB 200
    130 PRINT "MOST INEFFICIENT WAY TO SET L TO 0 COMPLETED"
    140 END
    200 LET L=L-1
    210 IF L>0 THEN GOSUB 200
    220 RETURN


    That won't work in all variants of BASIC. I'm not sure about any others, but GWBasic only stored a single return address, no matter how many GOSUB's you have. Basically, you had functions, but you couldn't call another function from within a function and still be able to get back to where you started. I'd say that qualifies for a WTF.

    Not true.  GW basic works just fine -- just tried the example above and it goes all the way. (copy from the gwbasic window:

    load "a"
    Ok 
    list
    100 REM RECURSION EXAMPLE
    110 LET L=10
    120 GOSUB 200
    130 PRINT "MOST INEFFICIENT WAY TO SET L TO 0 COMPLETED"
    140 END
    200 LET L=L-1
    210 IF L>0 THEN GOSUB 200
    220 RETURN
    Ok 
    run
    MOST INEFFICIENT WAY TO SET L TO 0 COMPLETED
    Ok 

    - ------------

    The classic basic has no procedures, no locals, no variable stack, and implementations generally had a fixed stack for GOSUBs. And it was specified in dox, that you can go 32/40/whatever levels deep before an error occours. Like this same gw-basic:

    list
    10 PRINT "*";
    20 GOSUB 10
    Ok 
    run
    ***********************************
    Out of memory in 10 
    Ok 

     

  • Thygrrr (unregistered) in reply to John Hensley
    Anonymous:
    Take note: This is what happens when an employer advertises for "CS degree or equivalent". If someone doesn't have a CS degree, they better be able to show you an outstanding portfolio of past work.


    I call BS!  (and that's not Bachelor of Science!)

    I've had people writing their thesis and they just UTTERLY DIDN'T KNOW TO CODE THEIR WAY OUT OF A ROOM WITH NO WALLS!

    With sites such as Rentacoder.com providing paid homework help for inept Computer Science students, it's just as much of a gamble as hiring someone without a degree.


    Yay, Captcha is "genius" :)
  • (cs) in reply to csrster
    Anonymous:
    From what I now know about computer science I actually wonder how they built a language which supports functions but _not_ recursion. It seems you would have to add extra logic to prevent adding an extra stack frame for the same function.

    Well, yes.

    Of course, you've already made an assumption - that stack frames are used. Think about an alternative mechanism, wherein each function had its own statically allocated 'frame' for its locals. At this point, you could have an arbitrary calling depth, but no function could be in that pile twice.

    Back in the days when stacks were much smaller than RAM, that might have made sense.

  • Tei (unregistered) in reply to Gunther VB
    Anonymous:

    Plus all the say.. 28+ year olds that don't even know OO exists, yet they try to mimic it vaguely by using an "ancestor" once in a while.

    I'm in hell.



    I am 32 years old programmer, and I love OOP. I even write elegant javascript code in OOP that is short than the equivalent procedural code!.

    --Tei
  • Holger Friedrich (unregistered) in reply to dpb

    <FONT style="BACKGROUND-COLOR: #d3d3d3">dpb wrote the following post at 05-31-2006 5:02 PM: </FONT>

    <FONT style="BACKGROUND-COLOR: #d3d3d3">[image] V.:</FONT>
    <FONT style="BACKGROUND-COLOR: #d3d3d3">Actually you can recurse with every language.
    In basic a recursion is a selective statement that jumps back || further in the code.
    </FONT>
    <FONT style="BACKGROUND-COLOR: #d3d3d3">The verb is actually "to recur," not "to recurse." As my CS prof always said, "To recur is to reexecute the same logic; to recurse is to curse again."

    //CAPTCHA = craptastic</FONT>

    Right.  And the noun would be "recurrence," not "recursion."

  • (cs) in reply to Anonymous Coward
    Anonymous:

    Anonymous:

    Recursion and iteration are essentially the same thing. And any compiler able to distinguish his ass from a hole in the ground will optimize a tail-call recursion into a loop anyway.

    Relying upon the compiler to do the tail recursion optimization is a bad idea. If optimizations get turned off for any reason, nasty things will start happening.

    "Frank, the program works fine in release mode, but whenever I try to debug it, BOOM!"

     

    Just use a language in which you can't turn tail-call optimization off in the first place (Scheme, Lisp, most if not all functional programming languages in fact).

  • i love disco (unregistered)

    First: Will do wonders to the team spirit when Greg's new subordinates find out that Greg posts their work to dailywtf  for the whole internet to look at.

    Second: I doubt that evaluating skill levels from smallish pieces of code is very effective. I would rather give them a piece of code and ask them to figure out what's wrong with it.

     

     

  • Bubu (unregistered)

    Don't see the big WTF here....

    Looks like something that evolved through time...

    Day X:
    We need this function... There are only 4 possible nesting levels - the last 2 depending on the special case objNode.NodeId. There will /never ever/ be more. - so the part till the nested if was built.

    Day X+A:
    We just made a redesign... Now there is another Level possible - so we are at a max of 5 levels - and there will /never ever/ be more... - so one else was added.

    Day X+A+B:
    On Level more - just an if added and else modified....

    And some alterations later the actual maintainer decided "I won't touch this piece of crap ;-)" - so they just used the good old cut-n-paste-technology - maybe even an emacs/vi-macro an F12 or so in the meantime ;-)

    So it's crap for shure... But I wouldn't be too surprised if many code-pieces evolve like this throughout the years. Shurely one could make a handy 5-liner out of this... But why ? It's ugly, braindamaged, ... yes. But it works. So why should someone invest the 20 minutes to rewrite it ???

  • (cs) in reply to i love disco
    Anonymous:
    Second: I doubt that evaluating skill levels from smallish pieces of code is very effective. I would rather give them a piece of code and ask them to figure out what's wrong with it

    Well, if they can't work out what's hideously wrong with their own code, what point is there in giving them someone else's?

  • (cs) in reply to MikiWatts
    MikiWatts:
    What, only 60 levels? why, back in my days, when we still wrote in white on blue, we went up to 120 levels with char assembly codes and we liked it, yes siree!


    Bah!  Back in my day, we recursed deep into 200 levels, in machine code (HEX), both ways, hum, under 3 feet of snow.

          -dZ.
  • andreas (unregistered)

    wtf are those guys doin' here?!

  • (cs) in reply to dpb
    Anonymous:
    V.:
    Actually you can recurse with every language.
    In basic a recursion is a selective statement that jumps back || further in the code.

    The verb is actually "to recur," not "to recurse." As my CS prof always said, "To recur is to reexecute the same logic; to recurse is to curse again."

    //CAPTCHA = craptastic



    Luckily, there are language nazis with better skills around (and perhaps a dictionary to boot!) to keep you straight.

    The noun is "Recursion", and its a term used in mathematics and computer science.  There is actually no real verb associated with this concept, other than "to perform recursion".  It is not "recur", as the concept of recursion involves more than just repetition.

    Some, more liberal, dictionaries (particularly online) have adopted "recurse" as a verb, perhaps because the use of the term is so prevalent nowadays.

         -dZ.

         -dZ.

  • (cs) in reply to Anonymous

    [image] Anonymous:
    I used to sell my assignments to other CS students.  They'd come up to me, actually crying, because they couldn't understand programming at even the most fundamental level.
     
    Paid my tuition that way.


    Not that I believe you, but if this was the case then you would lose in the long haul because you have to compete with a bunch of retards that have the same qualifications as yourself, thus lowering your potential earnings and job security.

     

    Why don't you believe him? I did the same thing. None of the people I helped ended up being developers but quite a few went into IT related fields (network admin, etc.). They weren't retards, they just couldn't code. If you really think that a couple of incompetent programmers with a piece of paper hurt your potential earnings and job security perhaps you are in the wrong field as well.

    As for recursion, we did that in first year. Unfortunately, due to hangovers beyond my control, I missed the first class where we were introduced to it so the following day when asked to write a tree traversal algorithm I came up with an "interesting" 900-line piece of crap that could be done in 5 lines with recursion.

  • (cs) in reply to Bubu
    Anonymous:
    Don't see the big WTF here....

    Shurely one could make a handy 5-liner out of this... But why ? It's ugly, braindamaged, ... yes. But it works. So why should someone invest the 20 minutes to rewrite it ???

    I'm glad you're not my colleague.

    And, BTW, it's "surely"'.
  • Richard (unregistered) in reply to steve

    I've met people, even in management, who are afraid of recursion.

    I once had to implement a "recursive" breadth first using a queue not because I needed breadth first but because management banned recursion.

  • Foo (unregistered)

    actually did what the function said it would, and only had a single case of undocumented and out-of-place mystery business logic

    Wait, where's the out-of-place mystery business logic?

    Wait... where's the logic?  I can see the monkey business... did you mean out-of-place monkey business logic?

  • Bubu (unregistered) in reply to bullestock

    "I'm glad you're not my colleague."

    Me too ;-)

    If there is time for rewriting ugly but working code - I'm with you. It should be done.

    But we really don't know how this piece evolved - maybe there've been much more if/then/else special-clauses in the meantime - and only the one posted survived... Who knows ?

    Fact 1: it's working.
    Fact 2: Out of purely aesthetic reasons you'd demand to fix it
    Fact 3: This /only/ makes sense if you really don't have any points of more importance on your todo-list...
    Fact 4: We don't know if this piece of code is very "volatile"... If there are changes to this piece on a daily/weekly basis, I'd still leave it as it is..
    Fact 5: If this piece - thrown out of it's context - is the one-and-only-really-big-WTF in the company - then it's a superb one ;-)

    P.S. 'And, BTW, it's "surely"' - thanks for the correction... haven't been writing in english for about 17 years - so many things have slipped my memory...

  • fusi (unregistered)

    HAHAHA

  • anonymous (unregistered) in reply to janoc

    Anonymous:
    Anonymous:

    Actually an interative solution is better because it won't cause a stack overflow when there are a million parent objects.  Those of you who thought of using recursion, consider yourself WTF-enabled.


    Educate yourself about the benefits of tail recursion and how to convert iteration to recursion and back (they are equivalent, surprise!). Then you wouldn't be WTF-enabled yourself.


     

    I'll go further, and say those of you who considered not using recursion in this case are WTF-enabled.  Iteration and recursion are mathematically equivalent, in a sense I won't try to explain to this group of ignorant twits, but if you want to write good code, you will use the method which reflects the problem at hand.  Things like "node level" are defined recursively, so they should be coded recursively.  Otherwise, your code will be ugly, and, therefore, wrong.

  • (cs) in reply to anonymous
    Anonymous:

    I'll go further, and say those of you who considered not using recursion in this case are WTF-enabled.  Iteration and recursion are mathematically equivalent, in a sense I won't try to explain to this group of ignorant twits, but if you want to write good code, you will use the method which reflects the problem at hand.  Things like "node level" are defined recursively, so they should be coded recursively.  Otherwise, your code will be ugly, and, therefore, wrong.

    You should use the method that best fits the problem at hand. Recursion may seem to be the most natural fit for the problem, however, recursion requires extra resources and incurs a performance problem over a loop. In this case, it would appear that a simple loop gives the best trade-off and is the best fit. Of course, by calling everyone ignorant twits you have demonstrated your immense superiority and have rendered all counter arguments, no matter how sensible, impotent. Well done, sir.

  • TheDoom (unregistered) in reply to adwadwawda
    Anonymous:
    Anonymous:
    Bus Raker:

    Anonymous:
    Take note: This is what happens when an employer advertises for "CS degree or equivalent". If someone doesn't have a CS degree, they better be able to show you an outstanding portfolio of past work.

    Well, if they have a CS degree, they should be hired and paid 6 figures without looking at anything.



    It used be the case in the 90s.  Anyone who knew how to turn a computer on could walk into any company and get hired on the spot.  Now, a CS degree is nearly worthless without relevant work exp in the field.
    I used to sell my assignments to other CS students.  They'd come up to me, actually crying, because they couldn't understand programming at even the most fundamental level.
     
    Paid my tuition that way.


    If you've got it, you've got it. I know people with CS degrees who cant understand a for next loop, also know loads of people with degrees in other subjects who are great coders.

    As someone without a CS degree it really shocks me to think lecturers are giving lectures about what an iteration is, surely this should be background reading? If the CS courses are this dumbed down, it would explain the number of highly dynamic IT consultants we see working for big companies who havent got the first clue about IT.
  • hush (unregistered) in reply to steve
    OMG - when will they start teaching recursion?


    To understand recursion, they will first have to understand recursion
  • phlox (unregistered)

    rofl. Thats a good one. But also could be autogenerated, saves time when you generate your code ;)

    Well, just give the objNode a Variable of integer called parentLevel.
    And if you create an objNode, its 0 if parent==0 else its parent->parentLevel+1;

    Or use iteration ;)

  • DaveK (unregistered) in reply to Xocomil
    Anonymous:
    No recursion is necessary to make this work. I'll edit this function to make it
    do what the code shows:

    Public
    Function GetNestingLevel(objNode As Node)

    If Not objNode.Parent Is Nothing Then
    GetNestingLevel = 0
    Else
    GetNestingLevel = 60
    End If



      Heh.  I can't believe how few people seem to have noticed that.  However, I think you're still not quite right: I think it should be more like:

    Public Function GetNestingLevel(objNode As Node)

    If Not objNode.Parent Is Nothing Then
    GetNestingLevel = 0
    Else
    [ raise an exception when you try to dereference Nothing.parent ]
    End If

          cheers,
             DaveK

  • Anonymouse (unregistered) in reply to Gene Wirchenko

    Gene Wirchenko:
    Anonymous:
    Dude, that was absolutely awful, and that was what he thought was the best of what his subordinates submitted. Frankly, it's such a WTF that I'm tempted to buy flowers for his next of kin and send my condolences in advance.


    Aside from the issue of expense, why not to the next of kin of the subordinates?

    Sincerely,

    Gene Wirchenko

    Because having to manage people like that is grounds for suicide? Keep in mind I see the wtf as that little function being the best of what the subordinates thought was their best code. Fighting that kind of institutionalized stupidity is like trying to fight the tides.

Leave a comment on “Living With Parents”

Log In or post as a guest

Replying to comment #:

« Return to Article