What's so good about OOP?

Originally posted by petesmc
I know this thread is a little bit old, but it is extremely useful…snip

I actually have this thread bookmarked in my main bookmarks folder. :smiley:

I generally use it to point people at for an explanation of OOP (cheers Vincent, saves my typing :smiley: :tup: ).

Matt. :slight_smile:

I thought about it a lot and that’s what I came up with:

There is no simple answer. It is possible to write an exceptionally good software using both techniques OOP as well as procedural.

It looks to me though, that OO approach provides better way to organize my software into building blocks - components. That helps me to accomplish my projects in shorter time and it helps me to communicate my ideas to other people.

But what classes do I need and what I don’t? That’s where it gets tricky! :slight_smile:

My advise: think for your self and experiment, experiment, experiment!

i’ll add my thoughts in the hope they may benefit someone and that i’ll get some feedback if i’m thinking looney.

major prinicple #1 - repeating code is not good. repeating code that may change in the future is bad. repeating code that will change in the future is reason to get your resume out - now! -lol-

i see a loose anology between OOP and database normalization. break the entity down to to its basic blocks. just like you can over normalize a database in some instances (or so i have read), you can probably over OOP in some cases, too.

in OOP you think in terms of the things some code does and then break it down to the unit level.

that doesn’t seem too hard, actually. once you envision that, then it is just a matter of learning the PHP OOP mechanics of getting all the small parts to work together.

if the OOPed to death (within reason, if the idea isn’t mutually exclusive) code is unacceptably slow, verify it is OOP that is causing this and decide if h/w can solve make the speed acceptable, if not very good for less than it will take you to un-OOP the code (and risk being wrong about the cause of the slowness). if the code is running nicely… you are living large.

also, think forward. assuming PHP’s OOP process isn’t optimized to an acceptable level right now, do you expect this to always be the case? do you want a ton of procedural (repeating code!) laying around in 2 years?

anyway, that’s my thought process. database normalization just makes sense. using PHP includes for repeating code (or functions) just makes sense. i think that OOP just makes sense as well.

i will have to learn the mechanics, though, and this thread is a great start. it can’t be nearly as hard as hacking css to work with all the top browsers! -lol-

having said that, i’m off to review my code to make updates!

Holy Old Thread, Batman!

how did i get here? not used to asking that question prior to drinking some beers! -lol-

I have seen some app use the define() to include and file or path just like and include() would to… How would I set this up… This is what I tried and I do not know if it is right or not

define('FILE', "/text.txt");

sorry wrong post!!