Sunday, February 26, 2012

Captain Kirk and Object Oriented Programming, According to my Dad

I’m taking a Java class right, and having a little bit of trouble wrapping my head around the concept of object-oriented programming and how to implement it. So, I asked my dad for some advice, and this is how he responded:

"Object oriented thinking:

Imagine a planet, any planet. How do you describe a planet? These are the properties.
The planet has it's own gravity,
It's own sky color,
It's own funny looking, sexy locals - if it is a 'star trek' type of planet
It's own monsters.

What do you do on the planet? These are the methods.
Look at the sky,
Chase the women
Run from the monsters

So Capt Kirk lands on Boiseity, what does he find?
Gravity - normal
Rainfall - dry
Local women - nice clean cut Mormons
Local monsters – chipmonks

These are the unique properties of the Boiseity planet.
Now Capt. Kirk lands on CapitolHillia, what does he find?
Gravity - .95 earth normal
Rainfall - wet
Local women - grunge
Local monsters – panhandlers

CapitolHillia and Boiseity are both unique objects of class Planet.”


Fighting aliens makes so much more sense than withdrawing funds from a bank account.

Hilarious, right?


Gaelyn said...

Like your Dad's story. Now, will you explain to me what object-oriented programming is?

Go Kirk!

Cujo359 said...

Yes, that's me doing OOP, except neither I nor the monster are that attractive...

Cujo359 said...
This comment has been removed by the author.
Cujo359 said...

Gaelyn, OOP is essentially a way of limiting programming problems to a relatively restricted set of options. To use the terminology in the article, "properties" are the variables the programmer is allowed to set or examine, and methods are the functions he can call to do things.

Most graphic user interface (GUI) environments are OOP, whether they're written in an object oriented language or not. The programmer sets up windows to look and operate a particular way using properties mostly, and then makes them appear for the user using "open window" method(s). Since the user could do anything at any time, programming this way makes a lot of sense in that environment.