Comment On Inheritance 101

At Barknee's place of work, it is pretty common place to have a "code walkthrough" when a project is complete. The idea is that other developers will have a general idea how system works in case they ever need to support it. [expand full text]
« PrevPage 1 | Page 2Next »

Re: Inheritance 101

2005-07-07 13:49 • by John Bigboote
Programming for Non-Shitheads

Chapter 3: Understanding loops

Re: Inheritance 101

2005-07-07 13:50 • by Ytram
Are you saying this is a bad example??  Upon what do you base this conclusion.  I think you're way off base.

Re: Inheritance 101

2005-07-07 13:51 • by RobIII

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

Re: Inheritance 101

2005-07-07 13:51 • by anonymous
37863 in reply to 37859
What loops ??? No need for loops. Just use the keywork base.

Re: Inheritance 101

2005-07-07 13:52 • by John Bigboote
Also, does this really have anything to do with inheritance? Isn't .Parent a reference to the physical container?

Re: Inheritance 101

2005-07-07 13:53 • by Manni
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.

Re: Inheritance 101

2005-07-07 13:56 • by Ytram
37866 in reply to 37864
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.

Re: Inheritance 101

2005-07-07 13:57 • by Sean
But without lengthy brute force code like this, my mad fast typing skills become less of a commodity.

Re: Inheritance 101

2005-07-07 13:58 • by Jeff S
37868 in reply to 37864

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? 


 

Re: Inheritance 101

2005-07-07 13:59 • by Jeff S
37869 in reply to 37866

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 !

Re: Inheritance 101

2005-07-07 14:03 • by Ytram
37870 in reply to 37869
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.

Re: Inheritance 101

2005-07-07 14:05 • by Free
Isn't that more like "Advanced Loop unrolling"?

Re: Inheritance 101

2005-07-07 14:06 • by Jeff S
37872 in reply to 37870

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?

Re: Inheritance 101

2005-07-07 14:06 • by Fregas

Oh fuck me...!


What a stupid ass monkey.

Re: Inheritance 101

2005-07-07 14:07 • by Matt B
37874 in reply to 37864
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.

Re: Inheritance 101

2005-07-07 14:08 • by Ytram
37875 in reply to 37870
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.

Re: Inheritance 101

2005-07-07 14:11 • by DanielR
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.

Re: Inheritance 101

2005-07-07 14:13 • by Ytram
37877 in reply to 37872
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.

Re: Inheritance 101

2005-07-07 14:15 • by anonymous
uhmmm do I see a need for recursive function here?

Re: Inheritance 101

2005-07-07 14:27 • by spacey
37880 in reply to 37878
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

Re: Inheritance 101

2005-07-07 14:31 • by ItsAllGeekToMe
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.............

Re: Inheritance 101

2005-07-07 14:46 • by Mike R
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.

Re: Inheritance 101

2005-07-07 14:48 • by spacey
37883 in reply to 37882
mike - i'd be runnin right behind ya =)



-space

Re: Inheritance 101

2005-07-07 14:49 • by curtisk
with all this parent on parent action, what do the kids look like??

Re: Inheritance 101

2005-07-07 14:49 • by Grandpa Ben
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

Re: Inheritance 101

2005-07-07 14:50 • by Grandpa Ben
37887 in reply to 37885
Hmm. The preview function on this forum doesn't do a very good job of it.

Re: Inheritance 101

2005-07-07 14:53 • by Mike R
37890 in reply to 37887
Anonymous:
Hmm. The preview function on this forum doesn't do a very good job of it.




Welcome to "The Daily WTF" [:P]

Re: Inheritance 101

2005-07-07 14:55 • by Matt Moriarity
37892 in reply to 37887
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.

Re: Inheritance 101

2005-07-07 14:56 • by Charles Nadolski
AAAAAAAAAARRRRRRRRGGGGGGGGGHHHHHHHHH!!!!! *runs screaming off interstate bridge*

Re: Inheritance 101

2005-07-07 15:04 • by lucio

I'll apply as senior from now on.

Re: Inheritance 101

2005-07-07 15:05 • by mgd

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

Re: Inheritance 101

2005-07-07 15:30 • by Jehos
37897 in reply to 37895
Anonymous:

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



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

Re: Inheritance 101

2005-07-07 15:45 • by mizhi
37899 in reply to 37876
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?

Re: Inheritance 101

2005-07-07 15:48 • by Ytram
37900 in reply to 37887
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...



(Just kidding Alex)

Re: Inheritance 101

2005-07-07 15:48 • by CornedBee
37901 in reply to 37897
Today's lesson: the if-statement:





public void anIfStatement()

{

}



this.anIfStatement();

Re: Inheritance 101

2005-07-07 15:55 • by cm5400
37902 in reply to 37893

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


Following your foot steps to the nearest, tallest bridge!

Re: Inheritance 101

2005-07-07 16:01 • by Miszou

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...

Re: Inheritance 101

2005-07-07 16:11 • by Michael Suzio
37906 in reply to 37868
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).

Re: Inheritance 101

2005-07-07 16:29 • by John Smallberries
37907 in reply to 37906
inheritance, composition, aggregation...let's not fight in front of the children!

Re: Inheritance 101

2005-07-07 16:51 • by spacey
37910 in reply to 37907
ROFL @ Jon



-space

Re: Inheritance 101

2005-07-07 16:53 • by Rick Mogstad
37911 in reply to 37906
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.......



;)

Re: Inheritance 101

2005-07-07 17:23 • by rikkus
37912 in reply to 37876
DanielR almost made me spray my tea.

Re: Inheritance 101

2005-07-07 17:54 • by strongarm
I think a more appropriate job title for this guy would be "Senior O2 to CO2 Converter" instead of Senior Developer.

Re: Inheritance 101

2005-07-07 18:04 • by BRH


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?
...



Re: Inheritance 101

2005-07-07 19:12 • by Chris F
Assuming 'Parent' has a similar InitializeDisplay method:



public void
InitializeDisplay () {

    if (IsActive) {

        Initialize();



        if (Parent != null)

            Parent.InitializeDisplay();

    }

}

Re: Inheritance 101

2005-07-07 19:15 • by clockwise
37919 in reply to 37859

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.

Re: Inheritance 101

2005-07-07 20:06 • by rogthefrog

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.

Re: Inheritance 101

2005-07-07 22:54 • by Jon Limjap
37934 in reply to 37921
This program oughta be called "Inherited Bastard."  

Re: Inheritance 101

2005-07-08 02:47 • by ammoQ
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 */ }


  }


}


Re: Inheritance 101

2005-07-08 03:38 • by dg
Somebody needs to refactor, bad!
« PrevPage 1 | Page 2Next »

Add Comment