| « Prev | Page 1 | Page 2 | Next » |
|
Programming for Non-Shitheads
Chapter 3: Understanding loops |
|
Are you saying this is a bad example?? Upon what do you base this conclusion. I think you're way off base.
|
|
Guess he had a problem with his parents when he was young [:D] |
|
What loops ??? No need for loops. Just use the keywork base.
|
|
Also, does this really have anything to do with inheritance? Isn't .Parent a reference to the physical container?
|
|
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.
|
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. |
|
But without lengthy brute force code like this, my mad fast typing skills become less of a commodity.
|
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?
|
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. |
|
Isn't that more like "Advanced Loop unrolling"?
|
So what is your point? What does that have to do with inheritance or the way this code was written? |
|
Oh fuck me...! What a stupid ass monkey. |
You guys missed the joke; it's "inheritance" as in it has parents and children. But not OO inheritance. |
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. |
|
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. |
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. |
|
uhmmm do I see a need for recursive function here?
|
|
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 |
|
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.............
|
|
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. |
|
mike - i'd be runnin right behind ya =)
-space |
|
with all this parent on parent action, what do the kids look like??
|
|
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 |
|
Hmm. The preview function on this forum doesn't do a very good job of it.
|
Welcome to "The Daily WTF" [:P] |
|
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.
|
|
AAAAAAAAAARRRRRRRRGGGGGGGGGHHHHHHHHH!!!!! *runs screaming off interstate bridge*
|
|
Maybe he should have demo'd recursion before he did inheritance. |
Yeah, then we could have seen GOTO statements as well. [:D] |
They do that in West Virginia, Alabama and some parts of Kentucky. Why use loops when you can make a family tree that cycles? |
You could always go back and edit your post. Oh wait... (Just kidding Alex) |
|
Today's lesson: the if-statement:
public void anIfStatement() { } this.anIfStatement(); |
Following your foot steps to the nearest, tallest bridge! |
|
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... |
|
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). |
|
inheritance, composition, aggregation...let's not fight in front of the children!
|
|
ROFL @ Jon
-space |
You'll want to take note of the language used in the example....... ;) |
|
DanielR almost made me spray my tea.
|
|
I think a more appropriate job title for this guy would be "Senior O2 to CO2 Converter" instead of Senior Developer.
|
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? |
|
Assuming 'Parent' has a similar InitializeDisplay method:
public void InitializeDisplay () { if (IsActive) { Initialize(); if (Parent != null) Parent.InitializeDisplay(); } } |
John, release the book and it'll sell. Actually I can help you write it: Programming for Non-Shitheads |
|
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. |
|
This program oughta be called "Inherited Bastard."
|
|
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)
|
| « Prev | Page 1 | Page 2 | Next » |