I LOVE OOP

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

User avatar
dallasx
Forum Contributor
Posts: 106
Joined: Thu Oct 20, 2005 4:55 pm
Location: California

Post by dallasx »

I should have referred to it as a class property earlier... sorry about that.

If you read this and are confused just ignore it.

My old German teacher once told me that the way you remember foreign languages (also applies to programming languages) is that you develop "donkey bridges" (whatever the hell that is). A "donkey bridge" would be a silly way that you remember something. For example, she told us that to remeber how to pronounce the common "EI" and "IE" in words by this dumb phrase: "If two vowels go a walkin', the second one does the talkin'." Meaning that the second vowel is the one that you pronounce.
EI sounds like I (eye)
IE sounds like E (gee)

So.. here is my "donkey bridge" with class properties and varaibles.
----------------------------
The way I think of class properties and local variables is this:

Class properties are the end of the line, the values you want.
Variables are used to funnel the values into the properties.


An illustration:
Filling a car's oil tank up. Upper case words will be the real life thing and the [brackets] will represents PHP.

You use a FUNNEL=[variable] to fill the OIL TANK=[class property]

That's a redneck way of saying it.

Let me know how that explaination was, anybody...
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

Post by blacksnday »

Thanks to everyone for explaining it so nicely.
Just this thread alone is giving me a huge heads-up compared to where I was
yesterday with OOP.

The way I tend to learn... is to do it now, and figure it out later. lol
Which is what I have done so far.
My main submit page I have been able to transfer all to OOP... however
not as extensive as I would like to eventually, its still my
'Learning Building Blocks'

btw... just 2 months ago I knew nothing about php
but now have created custom BB tags, a custom AdWord system, a shoutbox,
and the rest of my news script.

I learned by spending hours reading tuts, then just coding and reflecting back on it
later once my mind was able to asorb it.
So Im sure that with examples of OOP here, and with my current submit page
transformation done already...
I'm getting it :D

Some friends of mine have argued that my code doesnt need OOP,
but the way it keeps growing, and the way I am getting sick of
making craploads of functions that do nearly identical stuff, and
how I am frying my brain with all my forms and seperate code for each...
I know i need OOP and need it fast :D

Thanks all for the great help!
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Re: I LOVE OOP

Post by McGruff »

dallasx wrote:Now I love classes.
You'll love them even more once you get into unit testing - if you haven't already.
User avatar
dallasx
Forum Contributor
Posts: 106
Joined: Thu Oct 20, 2005 4:55 pm
Location: California

Re: I LOVE OOP

Post by dallasx »

McGruff wrote:
dallasx wrote:Now I love classes.
You'll love them even more once you get into unit testing - if you haven't already.
unit testing??
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

read the threads in the unit testing board... ;)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

dallasx wrote:
An illustration:
Filling a car's oil tank up. Upper case words will be the real life thing and the [brackets] will represents PHP.

You use a FUNNEL=[variable] to fill the OIL TANK=[class property]

That's a redneck way of saying it.
Actually in OOP i wouldn't care about the properties/data of a class.
I would care about the interface (public methods/behaviour) , fe: public Fill($amount) or public Empty($amount).
Post Reply