• (cs)

    Programming for Non-Shitheads
    Chapter 3: Understanding loops

  • (cs)

    Are you saying this is a bad example??  Upon what do you base this conclusion.  I think you're way off base.

  • (cs)

    Guess he had a problem with his parents when he was young [:D]

  • anonymous (unregistered) in reply to John Bigboote

    What loops ??? No need for loops. Just use the keywork base.

  • (cs)

    Also, does this really have anything to do with inheritance? Isn't .Parent a reference to the physical container?

  • (cs)

    Damn all this time I though inheritence meant getting a large bag with a dollar sign on it as a result of a rich, anonymous relative dying. Now I know, it's just referring directly to objects by going through the Parent tree. Jeez if only some clever group could come up with a way for me to just use the functions without going through all that "Parent.Parent..." crap.

  • (cs) in reply to John Bigboote
    John Bigboote:
    Also, does this really have anything to do with inheritance? Isn't .Parent a reference to the physical container?


    Depends on what's actually going on in the code.  If that was an asp.net page/control/etc, then Parent is indeed referring to the container that owns the current control.  From what it looks like though, it is some kind of ridiculous attempt at inheritance.
  • (cs)

    But without lengthy brute force code like this, my mad fast typing skills become less of a commodity.

  • (cs) in reply to John Bigboote

    John Bigboote:
    Also, does this really have anything to do with inheritance? Isn't .Parent a reference to the physical container?

    Exactly ....  No inheritance here !

    I'd love to see the rest of this system ... it does make you think, though.  What if you just started working at this company and were present for this informative demonstration?  What would you do or say? 

     

  • (cs) in reply to Ytram

    Ytram:
    John Bigboote:
    Also, does this really have anything to do with inheritance? Isn't .Parent a reference to the physical container?


    Depends on what's actually going on in the code.  If that was an asp.net page/control/etc, then Parent is indeed referring to the container that owns the current control.  From what it looks like though, it is some kind of ridiculous attempt at inheritance.

    That has nothing to do with inheritance !

  • (cs) in reply to Jeff S
    That has nothing to do with inheritance !


    Right, but we have no guarantee that this is code from within a asp.net page, or from a windows form.
  • (cs)

    Isn't that more like "Advanced Loop unrolling"?

  • (cs) in reply to Ytram

    Ytram:
    That has nothing to do with inheritance !


    Right, but we have no guarantee that this is code from within a asp.net page, or from a windows form.

    So what is your point?  What does that have to do with inheritance or the way this code was written?

  • Fregas (unregistered)

    Oh fuck me...!

    What a stupid ass monkey.

  • (cs) in reply to John Bigboote
    John Bigboote:
    Also, does this really have anything to do with inheritance? Isn't .Parent a reference to the physical container?


    You guys missed the joke; it's "inheritance" as in it has parents and children.

    But not OO inheritance.
  • (cs) in reply to Ytram
    Ytram:
    That has nothing to do with inheritance !


    Right, but we have no guarantee that this is code from within a asp.net page, or from a windows form.


    In fact, I'll go a bit further and just state that the code is not from a Web or Windows Form.  Since the call to .Parent is not being cast at all, and a method called Initialize()(which is not a method of the Control class) is being invoked, Parent cannot be either the Web or Windows control property named Parent.
  • DanielR (unregistered)

    Why didn't he write a GrandParent method that returns Parent.Parent?

    (this.Parent.Parent.Parent.Parent.Parent.Parent != null) --> (this.GrandParent.GrandParent.GrandParent != null)

    And while we're at it, let's add a Sister method, a BrotherInLaw method and a CrazyAuntYouOnlyMeetOnHolidays method.

  • (cs) in reply to Jeff S
    Jeff S:

    Ytram:
    That has nothing to do with inheritance !


    Right, but we have no guarantee that this is code from within a asp.net page, or from a windows form.

    So what is your point?  What does that have to do with inheritance or the way this code was written?



    The subject of the thread is inheritance and how this code was being used as an example of inheritance.  From the looks of the code, actual inheritance wasn't used.

    I was just pointing out to the poster that was saying the Parent property was a physical container, and I was merely pointing out that is the case in forms, but not in this code.
  • anonymous (unregistered)

    uhmmm do I see a need for recursive function here?

  • spacey (unregistered) in reply to anonymous

    i'd be severely pissed if my "senior architect" broke this crap out.

    i mean seriously....where did this senior guy come from? C# .NET via "Learn Access in 21 days and seven mins" ??

    wow - rather, WTF!

    -spacey

  • (cs)

    my brother's mom's dad's wife's mom's grandmother's uncle's cousin's husband's wife's cousin's niece's grandaughter's daughter's husband's daughter's son's brother, a.k.a. me, sees nothing wrong.............

  • (cs)

    If the app has that many levels of nesting of objects, then its very clear the "senior" deveoper had no clue. This is further supported by the claim that this parent.parent.parent.... chain is some form of inheritance.

    If this were a job I just started, I would run screaming toward the nearest exit. Actually, I would have loved to have seen this presentation, just to see how far out in left field this "programmer" was.

  • spacey (unregistered) in reply to Mike R

    mike - i'd be runnin right behind ya =)

    -space

  • (cs)

    with all this parent on parent action, what do the kids look like??

  • Grandpa Ben (unregistered)

    Many, many years ago when I was 23
    I was married to a Wider who was purty as can be
    This Wider had a grown-up daughter who had hair of red
    My father fell in love with her and soon they two were wed

    This made my dad my son-in-law and changed my very life
    For my daughter was my mother cause she was my father's wife
    To complicate the matter even though it brought me joy
    I soon became the father of a bouncing baby boy


    I'm my own grampa,
    I'm my own grampa
    It sounds funny I know
    But it really is so
    I'm my own grampa


    My little baby then became a brother-in-law to dad
    And so became my uncle though it made me very sad
    For if he was my uncle then that also made him brother
    Of the Wider's grown up daughter who of course was my step-mother

    My father's wife then had a son who kept them on the run
    And he became my granchild for he was my daughters son
    My wife is now my mother's mother and it makes me blue
    Because although she is my wife she's my grandmother too


    I'm my own grampa,
    I'm my own grampa
    It sounds funny I know
    But it really is so
    I'm my own grampa


    Oh if my wife is my grandmother then I'm her grandchild
    And every time I think of it, it nearly drives me wild
    For now I have become strangest case you ever saw
    As husband of my own grandmother I'm my own grampa


    I'm my own grampa,
    I'm my own grampa
    It sounds funny I know
    But it really is so
    I'm my own grampa

  • Grandpa Ben (unregistered) in reply to Grandpa Ben

    Hmm. The preview function on this forum doesn't do a very good job of it.

  • (cs) in reply to Grandpa Ben
    Anonymous:
    Hmm. The preview function on this forum doesn't do a very good job of it.


    Welcome to "The Daily WTF" [:P]
  • Matt Moriarity (unregistered) in reply to Grandpa Ben

    It might be smarter if each of the parent's just called their parent. then there would be only parent fall. obviously this person is too much of an idiot to think of that, tho.

  • (cs)

    AAAAAAAAAARRRRRRRRGGGGGGGGGHHHHHHHHH!!!!! runs screaming off interstate bridge

  • (cs)

    I'll apply as senior from now on.

  • mgd (unregistered)

    Maybe he should have demo'd recursion before he did inheritance.

  • (cs) in reply to mgd
    Anonymous:

    Maybe he should have demo'd recursion before he did inheritance.

    Yeah, then we could have seen GOTO statements as well.  [:D]

  • (cs) in reply to DanielR
    Anonymous:
    Why didn't he write a GrandParent method that returns Parent.Parent?

    (this.Parent.Parent.Parent.Parent.Parent.Parent != null) --> (this.GrandParent.GrandParent.GrandParent != null)

    And while we're at it, let's add a Sister method, a BrotherInLaw method and a CrazyAuntYouOnlyMeetOnHolidays method.



    They do that in West Virginia, Alabama and some parts of Kentucky.

    Why use loops when you can make a family tree that cycles?

  • (cs) in reply to Grandpa Ben
    Anonymous:
    Hmm. The preview function on this forum doesn't do a very good job of it.


    You could always go back and edit your post.

    Oh wait...

    <font size="1">(Just kidding Alex)</font>
  • (cs) in reply to Jehos

    Today's lesson: the if-statement:


    public void anIfStatement()
    {
    }

    this.anIfStatement();

  • (cs) in reply to Charles Nadolski

    Charles Nadolski:
    AAAAAAAAAARRRRRRRRGGGGGGGGGHHHHHHHHH!!!!! *runs screaming off interstate bridge*

    Following your foot steps to the nearest, tallest bridge!

  • (cs)

    Aside from the obvious mess, isn't it more usual for the parent to create/initialize its children?

    I'm finding it very difficult to imagine a scenario where child objects are responsible for initializing the parent...

  • Michael Suzio (unregistered) in reply to Jeff S

    I guess when someone tried to explain "composition" in objects, he got it a bit confused with "inheritance" and just went a bit overboard...

    I miss out on so much by working on a small team of people we've all personally interviewed and asked for code samples from.  Well, that and avoiding crappy languages in the first place (ducks VB.NET manuals being thrown at him).

  • (cs) in reply to Michael Suzio

    <font size="2">inheritance, composition, aggregation...let's not fight in front of the children!</font>

  • spacey (unregistered) in reply to John Smallberries

    ROFL @ Jon

    -space

  • (cs) in reply to Michael Suzio
    Anonymous:
    Well, that and avoiding crappy languages in the first place (ducks VB.NET manuals being thrown at him).


    You'll want to take note of the language used in the example.......

    ;)
  • (cs) in reply to DanielR

    DanielR almost made me spray my tea.

  • (cs)

    I think a more appropriate job title for this guy would be "Senior O2 to CO2 Converter" instead of Senior Developer.

  • BRH (unregistered)

    Alex Papadimoulis:
    public bool ProcessComponent()
    {
    return this.Parent.Parent.Parent.Parent.ProcessComponent();
    }


    Alex seems to have stripped out the comments from the code, which were quite informative. As a public service announcement, here they are:
    return this.Parent.ProcessComponent(); // Who's your daddy?
    return this.Parent.Parent.ProcessComponent(); // Who's your granddaddy?
    return this.Parent.Parent.Parent.ProcessComponent(); // Who's your great-granddaddy?
    ...


  • (cs)

    Assuming 'Parent' has a similar InitializeDisplay method:

    public void InitializeDisplay () {
        if (IsActive) {
            Initialize();

            if (Parent != null)
                Parent.InitializeDisplay();
        }
    }

  • (cs) in reply to John Bigboote

    John Bigboote:
    Programming for Non-Shitheads
    Chapter 3: Understanding loops

    John, release the book and it'll sell. Actually I can help you write it:

    Programming for Non-Shitheads
    Chapter 4: How to ignore shitheads.

  • (cs)

    Imagine the endless hours of fun you'd get by using slightly more colorful names.

    Gramps.Guvnor.Pops.Initialize();

    or

    Mammy.Grandma.Moogie.Initialize();

     

    Seriously, what kind of a MORON 1) writes that crap and 2) shows it off as an example of inheritance?

    There should be a "shoots random people then self" smiley on this board.

  • (cs) in reply to rogthefrog

    This program oughta be called "Inherited Bastard."  

  • (cs)

    Might be real OOP inheritance, who knows with seeing the rest of the code? (Of course this would mean the code was written by a programmer who couldn't find the base keyword)

    namespace WhatTheFrag {
       public class a1 {
          public void Initialize() { /* ... / }
      }

      public class a2 : a1 {
        private a1 Parent;
        public a2()  {
          Parent = this;
        }
        public void Initialize() { /
    ... */ }
      }

      public class a3 : a2 {

        private a2 Parent;

        public a3()  {

          Parent = this;

        }
        public void Initialize() { /* ... / }
      }

      /
    ... */

      public class a99 : a98 {

        private a98 Parent;

        public a99()  {

          Parent = this;

        }

        public void Initialize() { /* see original WTF */ }

      }

    }

  • dg (unregistered)

    Somebody needs to refactor, bad!

Leave a comment on “Inheritance 101”

Log In or post as a guest

Replying to comment #:

« Return to Article