Kuro5hin.org: technology and culture, from the trenches
create account | help/FAQ | contact | links | search | IRC | site news
[ Everything | Diaries | Technology | Science | Culture | Politics | Media | News | Internet | Op-Ed | Fiction | Meta | MLP ]
We need your support: buy an ad | premium membership

[P]
OOP Concept explained: Polymorphism (Technology)

By balsamic vinigga in Technology
Thu Mar 16, 2006 at 07:10:44 AM EST
Tags: Software (all tags)
Software

The problem with most computer science texts is the examples aren't interesting. Polymorphism isn't really hard to understand, but the examples are usually boring or difficult to understand. This is an alternative text which attempts to use a problem space that's already familiar to the college student to make the concepts of programming simple.

Pre-requisite skills You must be comfortable with classes and objects and read basic java/c# to follow this lesson.


Polymorphism shouldn't be a new concept to anybody. You deal with it every day in the real world. There's more than one class of cat to skin, but you skin 'em the same way, even if the specific instance is completely new to you. Let's say for example you want to fuck a hole. You fuck all holes the same. You don't care if that hole happens to be a mouth, an ass, or a pussy, you're gonna fuck it the same way regardless. However, the mouth, pussy, or ass may respond differently to the fucking.

So you have a common abstract class named 'Hole' and 3 concrete classes Pussy, Ass, and Mouth which all extend from Hole:


class Pussy extends Hole {}
class Mouth extends Hole {}
class Ass extends Hole {}

So, now let's say you have a Penis.Fuck(Hole h) method. The Penis class is unconcerned about what the specific Hole instance is, it's gonna fuck it the same regardless. Specificly we thrust the Hole with a Penis until the Penis is spent. Finally, we give the hole the Penis' load.


class Penis {
public Fuck(Hole h) {
while(!this.isSpent) {
h.TakeAThrust(this);
this.arousal++;
}
h.TakeALoad(this.load);
}
}

Now here's where polymorphism gets fun. The Hole will respond different to the thrusting and load depending on what specific type of Hole we're implementing.

First we must implement an abstract class which defines an abstract interface.


abstract class Hole {
public abstract void TakeAThrust(Penis p);

public abstract void TakeALoad(Load l);
}

Now all that's left is the varying implementations of these methods in the seperate concrete classes. For example, an Ass' implementation of TakeAThrust could look something like:


public void TakeAThrust(Penis p) {
if(!enoughLube && p.Circumference > 6) {
analFissureCount++;
}
}

See, the beauty of it is... the Penis doesn't even need to know it's fucking an Ass for the Ass to behave like a proper Ass.

Now, let's see how we might implement TakeALoad differently for Mouth and Pussy:


//in Pussy
public void TakeALoad(Load l) {
//randomly determine whether to cause a pregnancy with a 10% chance...
if(Math.RandomNumber() % 10 == 0) {
this.Woman.EggFactory.GetEgg().Inseminate(l);
}
}

//in Mouth
public void TakeALoad(Load l) {
//50-50 chance of spitting or swallowing
if(Math.RandomNumber() % 1 == 0) {
this.Spit(l);
} else {
this.Swallow(l);
}
}

Putting it all together with client code

Now that we have our classes well planned out with polymorphism in mind, we can see the kind of luxury it is for the client programmer to work with.


//create an array of 4 women
Woman[] women = new Woman[]{new Woman(), new Woman(), new Woman(), new Woman()};

//create a hole array to reference the holes of all 4 women, plus two additional holes.
Hole[] holes = new Hole[4*3 + 2];

for(int i = 0; i < women.Length; i++) {
holes[3 * i + 0] = women[i].Mouth;
holes[3 * i + 1] = women[i].Pussy;
holes[3 * i + 2] = women[i].Ass;
}

//additional holes (so the faggy programmers don't feel left out)
Man m = new Man();
holes[12] = m.Mouth;
holes[13] = m.Ass;

//now we loop through the holes and fuck them all with the same Penis

Penis p = new Man().Penis;

foreach(Hole h in holes) {
p.Fuck(h);
}

See how easy it makes it for the client programmer?

Thank you class, any questions?

Sponsors

Voxel dot net
o Managed Hosting
o VoxCAST Content Delivery
o Raw Infrastructure

Login

Poll
This lesson helped me better understand polymorphism in OOP
o yes 27%
o no 12%
o already understood it 60%

Votes: 74
Results | Other Polls

Related Links
o Also by balsamic vinigga


Display: Sort:
OOP Concept explained: Polymorphism (Technology) | 124 comments (109 topical, 15 editorial, 3 hidden)
if fuckers vote up debs stuff, they should +1FP (3.00 / 2) (#3)
by creativedissonance on Tue Mar 14, 2006 at 06:25:23 PM EST

especially whoever is controlling the clone trooper dupe horde.  I mean shit.


ay yo i run linux and word on the street
is that this is where i need to be to get my butt stuffed like a turkey - br14n
Check the voting results (none / 1) (#5)
by LilDebbie on Tue Mar 14, 2006 at 06:35:42 PM EST

We're almost identical.

My name is LilDebbie and I have a garden.
- hugin -

[ Parent ]
Auto Post III: The Search For Threshold (3.00 / 2) (#72)
by LilDebbie on Thu Mar 16, 2006 at 10:25:19 AM EST

Two stories, one gets posted: the difference in voting results and other variables supposedly used for the autopost was particularly narrow for these two. For future reference:

Total: 15
Votes: 254
FP: 86/118 (73%)
Topical Comments: 52
Ruling: Posted

Total: 13
Votes: 284
FP: 96/130 (74%)
Topical Comments: 43
Ruling: Dumped

My name is LilDebbie and I have a garden.
- hugin -

[ Parent ]

whoa (none / 1) (#77)
by balsamic vinigga on Thu Mar 16, 2006 at 11:41:28 AM EST

rusty, could we have a look at your algorythm? Can't believe how close these stories were...

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]
No revelation (none / 1) (#78)
by LilDebbie on Thu Mar 16, 2006 at 11:43:01 AM EST

He's afraid of "abuse" - whatever that means.

My name is LilDebbie and I have a garden.
- hugin -

[ Parent ]
But whatever system is used (none / 0) (#81)
by daveybaby on Thu Mar 16, 2006 at 12:42:20 PM EST

there is always going to be a situation where one article falls just on one side of the boundary case and another falls just on the other side.

[ Parent ]
Right (none / 0) (#82)
by LilDebbie on Thu Mar 16, 2006 at 12:51:03 PM EST

and that's what we have hear. However, with 3-4 different variables to work with, we're not sure weighting and whatnot.

My name is LilDebbie and I have a garden.
- hugin -

[ Parent ]
Ah, security by obscurity. I see. $ (none / 0) (#122)
by HackerCracker on Sun Aug 20, 2006 at 01:55:33 AM EST



[ Parent ]
Oh goddammit! (3.00 / 4) (#7)
by Lenticular Array on Tue Mar 14, 2006 at 06:48:52 PM EST

I voted -1 before I realized how vulgar your examples are.
ANONYMIZED
damn yuo knee jerk voters!!! $ (none / 1) (#8)
by balsamic vinigga on Tue Mar 14, 2006 at 06:50:58 PM EST



---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]
Can you write a tutorial for perl? (2.71 / 7) (#9)
by superdiva on Tue Mar 14, 2006 at 07:18:39 PM EST


_____________________________________________

Vote in Front Page poll: Best Scoop Writer for 2005
sure (2.00 / 3) (#10)
by balsamic vinigga on Tue Mar 14, 2006 at 07:25:13 PM EST

step 1: learn a different language for the love of God

step 2: that's all you need to know

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]

perl the language or pearl the necklace? (3.00 / 3) (#42)
by horny smurf on Wed Mar 15, 2006 at 03:57:59 PM EST

 

[ Parent ]
What would have been cool, except (none / 1) (#52)
by debacle on Wed Mar 15, 2006 at 07:01:11 PM EST

That she wrote 'perl.'

Retarded cumsucker.

It tastes sweet.
[ Parent ]

wtf? (3.00 / 1) (#56)
by horny smurf on Wed Mar 15, 2006 at 08:38:21 PM EST

you know that "it tastes sweet", but somehow I'm the cumsucker?

[ Parent ]
I know everything (none / 0) (#57)
by debacle on Wed Mar 15, 2006 at 08:41:34 PM EST

Which is why I'm aware that you swallow vast amount of semen on a near-daily schedule.

It tastes sweet.
[ Parent ]
really? (none / 0) (#59)
by horny smurf on Wed Mar 15, 2006 at 09:51:09 PM EST

That explains it... you're mad that I knocked up your girlfriend. Thanks for raising my son! He must be about 2.5 now.... Too bad (for you) she didn't swallow, huh?

[ Parent ]
Actually he'll be two and a half on March 21st (3.00 / 2) (#60)
by debacle on Wed Mar 15, 2006 at 10:11:56 PM EST

And I am fairly sure by your assertations on swallowing and the like that you don't even know how sex works.

It tastes sweet.
[ Parent ]
Were my book recommendations... (3.00 / 1) (#94)
by skyknight on Thu Mar 16, 2006 at 10:29:25 PM EST

insufficiently pornographic?

It's not much fun at the top. I envy the common people, their hearty meals and Bruce Springsteen and voting. --SIGNOR SPAGHETTI
[ Parent ]
Your recommendations were fine... (none / 0) (#108)
by superdiva on Fri Mar 17, 2006 at 01:29:29 PM EST

...just not enough holes.
_____________________________________________

Vote in Front Page poll: Best Scoop Writer for 2005
[ Parent ]
Naughty but nice (none / 0) (#14)
by stuaart on Tue Mar 14, 2006 at 07:43:56 PM EST


Linkwhore: [Hidden stories.] Baldrtainment: Corporate concubines and Baldrson: An Introspective


+1: Boring subject made fun. (none / 1) (#16)
by raaymoose on Tue Mar 14, 2006 at 08:07:07 PM EST

Good stuff.

dude (2.66 / 6) (#17)
by circletimessquare on Tue Mar 14, 2006 at 08:53:00 PM EST

you need to get laid

seriously badly

up here, neurons for coding

down there, hormones for fucking

the hormones need to be flushed on a regular basis, for if they are not flushed, they begin to flood the lower floors of the brain, and when these hormones flood up to the highest echelon of neurons- those having to do with OOP for chirssake, and begin to warp them with stuff like this story, then it's been a SERIOUSLY long time since you had your "get my freak on" hormones flushed

dude, go get laid

QUICK


The tigers of wrath are wiser than the horses of instruction.

are you volunteering to put out? (nt) (none / 1) (#18)
by t1ber on Tue Mar 14, 2006 at 08:56:00 PM EST


And she said...
Durka Durka Mohammed Jihad
Sherpa Sherpa Bak Allah
Hadji girl I can't understand what you're saying.

[ Parent ]

you can fuck me over (3.00 / 2) (#19)
by circletimessquare on Tue Mar 14, 2006 at 08:59:54 PM EST

but only in the forum of a k5 comment thread

god knows i've been fucking over dozens of people on a weekly basis the same way for years

;-P


The tigers of wrath are wiser than the horses of instruction.

[ Parent ]

You don't need the high neurons for OOPs (none / 1) (#91)
by Chewbacca Uncircumsized on Thu Mar 16, 2006 at 08:50:06 PM EST

An ape could do it.

[ Parent ]
jesus (none / 1) (#98)
by circletimessquare on Fri Mar 17, 2006 at 02:08:32 AM EST

what language/ method do you program in to claim that?

raw machine code?

what exalted sphere of programming do you inhabit where you think saying those words doesn't mean that you're a dick?


The tigers of wrath are wiser than the horses of instruction.

[ Parent ]

Who said (none / 0) (#116)
by Chewbacca Uncircumsized on Wed Mar 22, 2006 at 04:32:19 PM EST

I thought I wasn't being a dick when I said that?

[ Parent ]
This is too hard (1.00 / 3) (#22)
by United Fools on Tue Mar 14, 2006 at 10:31:16 PM EST

We cannot understand it. Can you first create a tutorial for something easier?
We are united, we are fools, and we are America!
+1 FP - fiction [nt] (none / 0) (#23)
by starched shirt collar on Tue Mar 14, 2006 at 11:56:37 PM EST



Virgin or lousy in the sack. (3.00 / 4) (#24)
by killmepleez on Wed Mar 15, 2006 at 12:38:28 AM EST

If you think all holes get fucked the same regardless, I feel sorry for your sexual partners (unless of course they're imaginary which, given the forum, is likely as not).

If you don't realize that different parts of the body respond to different types of stimulation*, then it's very possible that both people aren't getting off. If both people aren't getting off, then you're missing out on great sex, because great sex is all about mutuality.


e.g. amount/type of lubrication present, speed of initial insertion, insertion depth, thrust angle, thrust force, thrust frequency, and especially the degree to which those last three items are varied throughout the encounter, not to mention the many many combinations of peripheral stimulation which make it more intense for you both {yes, newsflash poindexter, great sex has as much to do with what's between your ears as what's between your legs -- and i've found this to be no less true with male partners than with female partners}

__
"I instantly realized that everything in my life that I thought was unfixable was totally fixable - except for having just jumped."
--from "J
man, the way you care about the pleasure (none / 1) (#25)
by balsamic vinigga on Wed Mar 15, 2006 at 12:48:10 AM EST

of bits of memory in a basic sex simulation program is almost scary...  and you're saying I'M the poindexter???

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]
I'm just a real stand-up guy like that. (none / 0) (#27)
by killmepleez on Wed Mar 15, 2006 at 01:23:31 AM EST



__
"I instantly realized that everything in my life that I thought was unfixable was totally fixable - except for having just jumped."
--from "J
[ Parent ]
great sex (2.84 / 13) (#41)
by horny smurf on Wed Mar 15, 2006 at 03:56:20 PM EST

great sex has as much to do with what's between your ears as what's between your legs

Read again, he implemented oral sex.

[ Parent ]

lofflesauce % (none / 0) (#51)
by creativedissonance on Wed Mar 15, 2006 at 05:59:11 PM EST




ay yo i run linux and word on the street
is that this is where i need to be to get my butt stuffed like a turkey - br14n
[ Parent ]
Parameter Optimisation (none / 0) (#119)
by daniasqui on Tue Apr 04, 2006 at 02:50:48 PM EST

Wow, that's a lot of parameters you have there to optimise -- you'll probably want to use a Genetic Algorithm for that :-)

[ Parent ]
-1, didn't explain how polymorph works. (none / 1) (#26)
by lukme on Wed Mar 15, 2006 at 01:18:05 AM EST




-----------------------------------
It's awfully hard to fly with eagles when you're a turkey.
not teaching how to (1.50 / 2) (#28)
by balsamic vinigga on Wed Mar 15, 2006 at 01:44:39 AM EST

write a compiler..  just teaching the concept.

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]
oh come on. (none / 1) (#32)
by lukme on Wed Mar 15, 2006 at 07:40:12 AM EST

Explaining polymorphism with a v-table and only considering single inheritance is straight forward. It is hardly enough to be able to write a C++ complier, since you also need to handle multiple inheritance (a feature that stroustrup goaded into adding to C++).

Unfortunately, if you don't have at least an outline of a model of how it works, then you really cannot make use of the feature.




-----------------------------------
It's awfully hard to fly with eagles when you're a turkey.
[ Parent ]
lol a multiple inheritence troll (2.50 / 6) (#35)
by balsamic vinigga on Wed Mar 15, 2006 at 08:57:22 AM EST

if you find yourself using C++, do yourself a favor and don't use multiple inheritence.

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]
I whole heartedly agree, however (3.00 / 2) (#75)
by lukme on Thu Mar 16, 2006 at 11:30:13 AM EST

You missed my point.

It is important to provide people with models as to how things work. The problem I have with the polymorphism as described in most textbooks is that doesn't provide a mechanistic way to consider how the program is working. As soon as I read how v-tables worked in C-Front (one possible implementation), I understood how polymorphism worked - and I understood when and how to use it.

The compiler people need to understand multiple inheritance since there are some nut cases who persist in using it. These are the people who believe that if a language feature exists, they need to use it.


-----------------------------------
It's awfully hard to fly with eagles when you're a turkey.
[ Parent ]
Infantile and obnoxious. (3.00 / 4) (#30)
by daveybaby on Wed Mar 15, 2006 at 05:55:18 AM EST

+1FP

Bug (3.00 / 3) (#31)
by psychologist on Wed Mar 15, 2006 at 06:31:27 AM EST

if(Math.RandomNumber() % 1 == 0)

Does that not always give the same result?

Also, I do not get some part of it. Let's say after you had used the penis for a long time, you later decide to switch to a dildo. Basically, it does the same things, but it does not have the ejaculate functionality. What would you do? Make a baseclass that defines an abstract Rod? So you would have PenisRod and DildoRod, with common functionality, right?

What about when you now want to use Love Balls? I can think of a number of things that are similar between a string of love balls and a dildo, however, the similarities between the love balls and penis are not as great. You have a dilemma there - do you inherit from rod or not? If you do not, do you not condemn yourself to a big mess?

Use multiple inheritance, I have a momy and daddy (none / 1) (#33)
by lukme on Wed Mar 15, 2006 at 07:58:46 AM EST

So must my objects.

A penis must inherit from both rod and ball, since it needs the rounded shape at one end.

Just think of the possibilities!!!

//
//Actually this is why I don't write C++
//For my personal projects.
//


-----------------------------------
It's awfully hard to fly with eagles when you're a turkey.
[ Parent ]
easy (2.00 / 3) (#34)
by balsamic vinigga on Wed Mar 15, 2006 at 08:54:43 AM EST

in this case, if the dildo and love balls have a comon interface you simply create an ISexToy interface.  Sure, you must now implement HasBatteries twice, but it's better than the alternative (multiple inheritence)

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]
Yup, interfaces are very like "mixins" (none / 0) (#73)
by rpresser on Thu Mar 16, 2006 at 10:30:32 AM EST

Or you could go really crazy and start using Aspect Oriented Programming
------------
"In terms of both hyperbolic overreaching and eventual wrongness, the Permanent [Republican] Majority has set a new, and truly difficult to beat, standard." --rusty
[ Parent ]
Crazy? (3.00 / 2) (#113)
by curunir on Fri Mar 17, 2006 at 04:43:35 PM EST

AOP makes complete sense here. As is often the case, security for this scenario is best implemented as an AOP aspect. You'd want before advice on the insert method to IoC in an object implementing the Protection interface. Normally, this would be a Condom object, but if you were relatively unconcerned about viruses (i.e. running on an a closed network), it could be something else (Diaphragm, etc).

[ Parent ]
+10 MILLION FP ALL THE WAY (none / 0) (#36)
by ChefSalad on Wed Mar 15, 2006 at 12:29:47 PM EST

I don't get why people are voting this down. It's hilarious AND informative. I think maybe they're just jealous that they didn't think of it first.

I was anonymized for submitting rusty fanfic to the queue in poor taste involving gay sex, aids, and a rusty nail. Let me serve as lesson for all.
I voted against it (3.00 / 2) (#37)
by aphrael on Wed Mar 15, 2006 at 12:41:12 PM EST

because it instantly makes this site NSFW and because it would offend almost all of my female friends.

Discussion is one thing. Deliberate offensiveness is another.

[ Parent ]

you hang with an uptight crowd (1.75 / 4) (#38)
by balsamic vinigga on Wed Mar 15, 2006 at 01:23:01 PM EST

I assume all you female friends must be thoroughly offended by rap and dave chapelle's comedy?

And since when is K5 SFW? that's the best joke i've seen in a long time, especially from you aph.

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]

you should get out more (2.00 / 3) (#39)
by balsamic vinigga on Wed Mar 15, 2006 at 03:06:31 PM EST

and you'll see that it's usually the females who get most excited and sing along when the DJ spins Ain't No Fun

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]
by the way (3.00 / 2) (#40)
by balsamic vinigga on Wed Mar 15, 2006 at 03:21:56 PM EST

i'll let me0w and motelbedspread know they're not your friend nor ever will be.

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]
that's reading an awful lot into my comment. (none / 0) (#44)
by aphrael on Wed Mar 15, 2006 at 04:30:12 PM EST

particularly where you conflate 'almost all' with 'all'.

[ Parent ]
ah, my apologies, no really (1.75 / 4) (#48)
by balsamic vinigga on Wed Mar 15, 2006 at 05:04:43 PM EST

i should be more careful when i read your shit.

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]
janra had something interesting to say (3.00 / 7) (#53)
by David Foster Wallace on Wed Mar 15, 2006 at 07:51:14 PM EST

In the latest site news1, janra2 stated "K5 has never been a 'PG 13' site and we have no interest in making it such a thing."3  So I say cock and balls for everyone.4

1 http://www.kuro5hin.org/story/2005/10/17/21492/251
2 http://www.kuro5hin.org/user/janra
3 I apologize for the USa-centric nature of this analogy.
4 Not literally everyone, I'm not a pedofileb or rapist.
a A large country in north america.
b (sic)

[ Parent ]

true. (3.00 / 2) (#54)
by aphrael on Wed Mar 15, 2006 at 08:01:33 PM EST

i have no interest in making it a pg-13 site, and i have no real problem with graphic descriptions of sex.

what bothered me about this, the reason i think my friends would find it offensive, and the reason i found it offensive, is that it was vaguely disrespectful and seemed to be the equivalent of what you would hear in a junior high school locker room.

[ Parent ]

What's new? (none / 1) (#55)
by ChefSalad on Wed Mar 15, 2006 at 08:30:36 PM EST

k5 IS a middle school locker room. Or didn't you get the memo. And besides, why would your female friends be offended? All of my female friends (who know a damn about programming) loved it and thought it was great. It would be beyond any non-programmer's head anyway, so why would be concerned about them? It's not like they're going to read it.

I was anonymized for submitting rusty fanfic to the queue in poor taste involving gay sex, aids, and a rusty nail. Let me serve as lesson for all.
[ Parent ]
My, you *are* a pantywaist. (none / 1) (#62)
by Lenticular Array on Wed Mar 15, 2006 at 10:52:14 PM EST


ANONYMIZED
[ Parent ]
Yes, yes it is. (3.00 / 3) (#68)
by ksandstr on Thu Mar 16, 2006 at 09:06:39 AM EST

Which is exactly why I voted it up.

We've already had the undigested fecal peanuts article here, and the fuck natalee holloway article, and the article about the world's most precious human vegetable. One object model of a penis fucking abstract, polymorphic holes in a while loop can't be much worse.

The author might have wanted to use interfaces instead of abstract classes (displaying his n00bitude, or a C++ background), and were I in his place I'd have written a bit about object modeling and that while more detail could've been put in, it's often far better not to overengineer such simple things. But then it would've been an article about object modeling instead of polymorphism.

Fin.
[ Parent ]

and on all of those things (none / 1) (#88)
by aphrael on Thu Mar 16, 2006 at 03:52:30 PM EST

i would have voted them down if i'd seen them in the queue.

[ Parent ]
use your dupe-horde for good, aprael! % (none / 0) (#112)
by creativedissonance on Fri Mar 17, 2006 at 02:07:24 PM EST




ay yo i run linux and word on the street
is that this is where i need to be to get my butt stuffed like a turkey - br14n
[ Parent ]
Sweet account! (none / 1) (#61)
by Lenticular Array on Wed Mar 15, 2006 at 10:37:31 PM EST


ANONYMIZED
[ Parent ]
Thank you (none / 1) (#63)
by David Foster Wallace on Wed Mar 15, 2006 at 11:02:03 PM EST

I find that quite encouraging.  The only problem is that now a comment takes about 20 minutes to write instead of 1 or 2.  Ah well, that's the life of a genius.1

1 http://www.lobsterlib.com/feat/davidwallace/index.asp

[ Parent ]

Bastard. (none / 0) (#76)
by The Diary Section on Thu Mar 16, 2006 at 11:37:28 AM EST

I wish I'd thought of that.
Spend 10 minutes in the company of an American and you end up feeling like a Keats or a Shelley: Thin, brilliant, suave, and desperate for industrial-scale quantities of opium.
[ Parent ]
It needs an if (8==D) comparison. (3.00 / 11) (#43)
by The Vast Right Wing Conspiracy on Wed Mar 15, 2006 at 04:00:32 PM EST



___
I'm a pompous windbag, I take myself far too seriously, and I single-handedly messed up K5 by causing the fiction section to be created. --localroger

I'm thinking... (none / 0) (#100)
by NoMoreNicksLeft on Fri Mar 17, 2006 at 02:53:39 AM EST

This should be an overloaded operator maybe.

--
Do not look directly into laser with remaining good eye.
[ Parent ]
You may not have realized (none / 1) (#46)
by rpresser on Wed Mar 15, 2006 at 04:51:01 PM EST

There is a lot of actual code that uses these concepts (or should use them, anyway). Take a look at this and this and this.
------------
"In terms of both hyperbolic overreaching and eventual wrongness, the Permanent [Republican] Majority has set a new, and truly difficult to beat, standard." --rusty
+1SP, clever and has pedo value (3.00 / 3) (#65)
by nostalgiphile on Thu Mar 16, 2006 at 03:28:47 AM EST

Pedogogical values, I mean.

"Depending on your perspective you are an optimist or a pessimist[,] and a hopeless one too." --trhurler
haha (1.50 / 2) (#66)
by balsamic vinigga on Thu Mar 16, 2006 at 06:27:24 AM EST

well the pedo's will probably have more performant code....  the better it performs the younger your object instances will be before you get to fuck em. :P

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]
this is incredibly sexist (none / 1) (#67)
by hardcorejon on Thu Mar 16, 2006 at 07:10:16 AM EST

I mean, seriously:

//create an array of 4 women
Woman[] women = new Woman[]{new Woman(), new Woman(), new Woman(), new Woman()};


Is there really only a default constructor for Woman? Should she at least get a name or something? This article presumes that all women are created anonymously and are indistinguishable and interchangeable.

+1FP

- jonathan.

their names (none / 1) (#69)
by Viliam Bur on Thu Mar 16, 2006 at 09:09:58 AM EST

are randomly generated

so one does not have to feel guilty if one forgets them

[ Parent ]

They are all created anonymous (3.00 / 2) (#74)
by Phssthpok on Thu Mar 16, 2006 at 10:37:27 AM EST

Names and other distinguishing features are acquired during initialization.
____________

affective flattening has caused me to kill 11,357 people

[ Parent ]
word up% (none / 0) (#111)
by creativedissonance on Fri Mar 17, 2006 at 02:05:56 PM EST




ay yo i run linux and word on the street
is that this is where i need to be to get my butt stuffed like a turkey - br14n
[ Parent ]
check the included CD for complete source files (none / 1) (#79)
by balsamic vinigga on Thu Mar 16, 2006 at 11:49:40 AM EST

but let me cut and paste the part you might be interested in.


/default constructor
public Woman() : this("My Bitch", 16.5, CupSize.DD, Race.Eurasian, CookingSkill.Moderate, new Height(5,3), 87, true) {
  //do nothing
}

public Woman(stirng name, float age, CupSize cupsize, Race race, CookingSkill cookSkill, Height h, int weight, bool enjoysShakespear) {
 
* .. */
}


---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]

There's actually a real world use for this (none / 0) (#70)
by ksandstr on Thu Mar 16, 2006 at 09:11:49 AM EST

See the adult interactive fiction (aka AIF) libraries for something like TADS. Well, for sufficiently small amounts of "real" anyway.

Fin.
Like I already said (none / 1) (#71)
by rpresser on Thu Mar 16, 2006 at 10:22:49 AM EST

in my comment below
------------
"In terms of both hyperbolic overreaching and eventual wrongness, the Permanent [Republican] Majority has set a new, and truly difficult to beat, standard." --rusty
[ Parent ]
Is this part of a series? (3.00 / 2) (#80)
by creature on Thu Mar 16, 2006 at 12:28:44 PM EST

I certainly hope so.

other types of polymorphism (none / 1) (#83)
by mrbastard on Thu Mar 16, 2006 at 01:27:35 PM EST

There are other types of polymorphism. In particular the compile time (as opposed to runtime, using a vtable or whatever) polymorphism offered by C++ templates is worth mentioning. Templates let me write dick functions that will not only work with any hole, but don't spend a lot of time fumbling to get it in the right hole during the main event, as it were.

"ohmygod I have a boyfriend" - Wen Jian

Where's LilDebbie's article? (3.00 / 2) (#84)
by bamcquern on Thu Mar 16, 2006 at 02:01:13 PM EST



I think the man just fucked himself in the ass (none / 0) (#85)
by nidarus on Thu Mar 16, 2006 at 03:24:03 PM EST

Was that the point?

Ah wait, it was a different man (none / 0) (#86)
by nidarus on Thu Mar 16, 2006 at 03:29:04 PM EST

:*(

[ Parent ]
hmm, seems like we should still guard against that (2.00 / 3) (#87)
by balsamic vinigga on Thu Mar 16, 2006 at 03:38:12 PM EST

use case. The TakeAThrustMethod should throw a "unfuckableHoleException" if the hole's owner is the same as the penis' owner.  Oh unless it's the Mouth class and the mutual owner's .Name == "LilDebbie." Again, we see the merits of polymorphism here.

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]
Interfaces (3.00 / 5) (#89)
by Baldrson on Thu Mar 16, 2006 at 06:54:19 PM EST

Your example is hardly an adequate introduction to the concept of polymorphism since if focuses simply on inheritance raher than true information hiding. There is nothing about the Fuck method that has to apply only to Holes. You might have an interface that includes the Fuck method and have a variety of classes that implement the Fuck method independently. For example, you might have a class CFO and another class Stockholders and end up with something like:

cfo.Fuck(sh)

-------- Empty the Cities --------


not sure what you mean (1.50 / 2) (#90)
by balsamic vinigga on Thu Mar 16, 2006 at 07:29:27 PM EST

Your example is hardly an adequate introduction to the concept of polymorphism since if focuses simply on inheritance raher than true information hiding.

hiding information beyond an unknown sub type? What do you mean by that? Parametrized types aka templates/generics? Yeah, usually we learn to stay in a type heirarchy first.  No need for an introduction to go into parametrized types.  Maybe next lesson.

There is nothing about the Fuck method that has to apply only to Holes.

Did you read the example? Look at the implementation of Fuck, it requires the Hole interface (Hole::TakeAThrust being a member of that interface.)

You might have an interface that includes the Fuck method and have a variety of classes that implement the Fuck method independently.

Again, did you even read the damn thing? The single Penis interface/class includes the Fuck method. The variety of subclasses of Hole implement TakeAThrust and TakeALoad independently.

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]

You realize, of course... (3.00 / 2) (#92)
by NoMoreNicksLeft on Thu Mar 16, 2006 at 09:02:17 PM EST

If you could somehow only post comments like this, we'd crown you king of K5, right?

I'm having a hard time resolving this with what I think of you. I mean, you're taking the joke and running with it? Maybe you're some ubergeek who is actually pointing out an actual flaw in the definitions and his presentation, when it's only a joke? Maybe your just trying to confuse those that believe you only post about your favorite subjects... I do not know.

Whichever it is, I wish I could rate this comment a 19 out of 3.

--
Do not look directly into laser with remaining good eye.
[ Parent ]

don't have to dig too deep to see what's (1.50 / 2) (#93)
by balsamic vinigga on Thu Mar 16, 2006 at 10:04:46 PM EST

going on here.  He's probably one of the few people here who actually believe I'm black, so he felt obligated to post something that would maintain an illusion of superiority over blacks.

However, as per my direct comment to him, he failed miserably at doing this.. though that is only obvious to people who thoroughly understand polymorphism in OOP...

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]

Heh. (none / 0) (#96)
by NoMoreNicksLeft on Thu Mar 16, 2006 at 11:09:18 PM EST

I get the impression that he was more inflamed by you not believing in his particular programming philosophies. Who knows.

Me, just a tinkerer... never been much. Though I've read most of the books, and I'm able to diddle around in C++ a bit. I've even submitted a few patches to some OSS projects. I'm still not sure if my last comment here revealed me for the dumbass that I am or not.

--
Do not look directly into laser with remaining good eye.
[ Parent ]

fuck it dude, who cares? (1.50 / 2) (#97)
by balsamic vinigga on Thu Mar 16, 2006 at 11:59:48 PM EST

if you can code up the pdatabase without it then my hats off to you, sir.

us conceptual programmers can waste all our time writing webpage after webpage of faggy pattern theories and never once develop anything as useful as your SVG dildos.

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]

Haha. (none / 0) (#99)
by NoMoreNicksLeft on Fri Mar 17, 2006 at 02:50:20 AM EST

Yeh, but it's hurting where I'm trying to do stuff like modest 3d rendering.

I'm more optimistic than I was 3 months ago, but alot of it seems daunting.

--
Do not look directly into laser with remaining good eye.
[ Parent ]

This does not bode well for K5. $ (none / 1) (#95)
by skyknight on Thu Mar 16, 2006 at 10:30:34 PM EST



It's not much fun at the top. I envy the common people, their hearty meals and Bruce Springsteen and voting. --SIGNOR SPAGHETTI
shut the hell up you stupid whiny pussy % (none / 0) (#110)
by creativedissonance on Fri Mar 17, 2006 at 02:04:14 PM EST




ay yo i run linux and word on the street
is that this is where i need to be to get my butt stuffed like a turkey - br14n
[ Parent ]
Eat your liver, swine. $ (none / 0) (#114)
by skyknight on Sat Mar 18, 2006 at 08:22:26 AM EST



It's not much fun at the top. I envy the common people, their hearty meals and Bruce Springsteen and voting. --SIGNOR SPAGHETTI
[ Parent ]
Enhanced OO Design (none / 0) (#101)
by jalava on Fri Mar 17, 2006 at 06:13:18 AM EST

I would enhance that bit further. interface Fuckable { public abstract void TakeAThrust(Penis p); public abstract void TakeALoad(Load l); } interface Fucker { public abstract void Fuck(Fuckable f); } of course, now Hole would implement Fuckable. Why this? Of course, because of the Fist! public class Fist implements Fuckable, Fucker { .. code here } This allows for example lesbian fist fuck action. new Woman().getFist().fuck(new Woman().getAss()); and gay mutual masturbation: Man man1 = new Man(); Man man2 = new Man(); man1.getPenis().fuck(man2.getFist()); man2.getPenis().fuck(man1.getFist()); You can see the limitless possibilities in here!

Cleanup.. (3.00 / 2) (#102)
by jalava on Fri Mar 17, 2006 at 06:17:07 AM EST


I would enhance that bit further.

interface Fuckable {
    public abstract void TakeAThrust(Penis p);
    public abstract void TakeALoad(Load l);
}

interface Fucker {
    public abstract void Fuck(Fuckable f);
}

of course, now Hole would implement Fuckable.

Why this? Of course, because of the Fist!

public class Fist implements Fuckable, Fucker { .. code here }
This allows for example lesbian fist fuck action:

new Woman().getFist().fuck(new Woman().getAss());

and gay mutual masturbation:

Man man1 = new Man();
Man man2 = new Man();
man1.getPenis().fuck(man2.getFist());
man2.getPenis().fuck(man1.getFist());

You can see the limitless possibilities in here!


[ Parent ]

brilliant (2.00 / 3) (#105)
by balsamic vinigga on Fri Mar 17, 2006 at 10:07:44 AM EST

this shoulda been a homework excersize.

it also enables for children on the play ground to fuck eachothers fists with their fists.

new kid().getFist().fuck(new kid().getFist());

omg here's a horrible programming pun:

{ new kid(); new kid(); new kid(); }  //new kids on the block

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]

I TAKE BACK MY +1 FP (3.00 / 3) (#109)
by creativedissonance on Fri Mar 17, 2006 at 02:03:59 PM EST

DIE FUCKER DIE


ay yo i run linux and word on the street
is that this is where i need to be to get my butt stuffed like a turkey - br14n
[ Parent ]
Bug (none / 0) (#106)
by jandev on Fri Mar 17, 2006 at 11:25:34 AM EST

interface Fuckable {
  public abstract void TakeAThrust(Fucker p);
  public abstract void TakeALoad(Load l);
}

HTH


"ENGINEERS" IS NOT POSSESSIVE. IT'S A PLURAL. YOU DO NOT MOTHERFUCKING MARK A PLURAL WITH A COCKSUCKING APOSTROPHE. APOSTROPHES ARE FOR MARKING POSSESSIVES IN THIS CASE. IF YOU WEREN'T A TOTAL MORON, YOU WOULD BE SAYING SOMETHING LIKE "THE CIVIL ENGINEER'S SMALL PENIS". SEE THAT APOSTROPHE? IT'S A HAPPY APOSTROPHE. IT'S NOT BEING ABUSED BY SOME GODDAMN SHIT-FOR-BRAINS IDIOT WITH NO EDUCATION. - Nimey
[ Parent ]

Brilliant (none / 0) (#103)
by n8f8 on Fri Mar 17, 2006 at 08:07:19 AM EST

I bow to your uber teaching skills.

Sig: (This will get posted after your comments)
50-50 chance ... (none / 0) (#104)
by wejn on Fri Mar 17, 2006 at 09:31:04 AM EST

$ ruby -e '(0..10).each do |i| puts i % 1; end'
0
0
0
0
0
0
0
0
0
0
0

Based on the test above I'd say it's a 100-0 chance. Poor you ;)

haha yup it's a bug (none / 1) (#107)
by balsamic vinigga on Fri Mar 17, 2006 at 01:09:25 PM EST

should be 2, i'll cop to that.

shoulda wrote an NUnit test!!!

---
Please help fund a Filipino Horror Movie. It's been in limbo since 2007 due to lack of funding. Please donate today!
[ Parent ]

Nice but kind of incomplete (none / 1) (#115)
by nakor on Sat Mar 18, 2006 at 04:11:54 PM EST

Where are the nostril and ear subclasses?

It's OO, dumbass. (3.00 / 2) (#117)
by trejkaz on Sat Mar 25, 2006 at 12:45:21 AM EST

You can write those subclasses yourself. That's the whole point.

[ Parent ]
Mistake ! (none / 0) (#118)
by javacub on Fri Mar 31, 2006 at 08:49:11 AM EST

//in Mouth public void TakeALoad(Load l) { //50-50 chance of spitting or swallowing if(Math.RandomNumber() % 1 == 0) { this.Spit(l); } else { this.Swallow(l); } } It should be % 2 .... otherwise it will spit everytime :)) by cub

A problem space familiar to the college student? (3.00 / 3) (#120)
by CptPicard on Wed May 24, 2006 at 09:00:05 PM EST

I am a CS major, could you please elaborate what exactly I am supposed to be familiar with in these examples? Your choices of object and method names and their uses seem like greek to me.

I have thought that this article is very good (none / 1) (#123)
by aldara on Fri Apr 06, 2007 at 12:00:51 AM EST

I have thought that this article is very good
¼âÈñʪðà


I have thought that this article is very good (none / 1) (#124)
by aldara on Fri Apr 06, 2007 at 12:02:04 AM EST

I have thought that this article is very good
¼âÈñʪðà

One correction (none / 1) (#125)
by Evandream on Sun May 06, 2007 at 03:37:21 PM EST

i think it has a mistake
abstract class Hole {
  public abstract void TakeAThrust(Penis p);

  public abstract void TakeALoad(Load l);
}

The below script should contain different tags PO and LIT

public void TakeAThrust(Penis p) {
  if(!enoughLube && p.Circumference > 6) {
    analFissureCount++;
  }
 fsbo mls for example this phrase should contain tags void Take and Count ++ = ))) Circumference:

OOP Concept explained: Polymorphism (Technology) | 124 comments (109 topical, 15 editorial, 3 hidden)
Display: Sort:

kuro5hin.org

[XML]
All trademarks and copyrights on this page are owned by their respective companies. The Rest 2000 - Present Kuro5hin.org Inc.
See our legalese page for copyright policies. Please also read our Privacy Policy.
Kuro5hin.org is powered by Free Software, including Apache, Perl, and Linux, The Scoop Engine that runs this site is freely available, under the terms of the GPL.
Need some help? Email help@kuro5hin.org.
My heart's the long stairs.

Powered by Scoop create account | help/FAQ | mission | links | search | IRC | YOU choose the stories!