Click to See Complete Forum and Search --> : Oop


SPo0n
04-26-2003, 09:30 PM
Ok i've searched alot for this, and read alot of stuff which is quite frankly bull.

What's the benefits of this object orientated stuff? All i can see is a bunch of functions put together in a "class", and alot of $this->that. I'm talking from a PHP perspective btw, but i'm aware OOP applies to other languages aswell.

It seems to be mainly code reuse, but the amount of code you need to write for OOP seems to defy the point of saving time/effort.

Someone correct me or point me to a good guide. Thanks

inkedmn
04-26-2003, 11:16 PM
Originally posted by SPo0n

It seems to be mainly code reuse, but the amount of code you need to write for OOP seems to defy the point of saving time/effort.


you're contradicting yourself. yes, it may take longer to code base classes than to hack out procedural stuff, but you'll save oodles of time when that base class is exactly what you need for another project.

download this (http://www.mindview.net/Books/TIJ/) book and read the first couple chapters. the examples are in java, but the ideas and concepts are universal.

stoe
04-28-2003, 04:39 PM
You're right, much of what you read about the supposed benefits of using oop is bull ... obviously, c++ doesn't enable you to code anything that you wouldn't have been able to do in c.

however, there are benefits ... if you are a programmer who writes clean, modularized, elegant code, then oop will be helpful. an oop language basically gives you a means of enforcing discipline in your own code and that of team members working on the same project. thats really it.

with that said, its entirely possible to write clean, modularized, and elegant code in a procedural manner, but the compiler/language will not help you much.

true, writing good object oriented code is more difficult than hacking out a sloppy procedural implementation of whatever your trying to do ... but in the long run, maintainability and stability are sacrificed if time is not put in to make a good design. oop gives you tools to more easily implement a clean design.

my purpose in writing this was not to take a stab at c or procedural programming in general ... its absolutely possible to write good, clean, modular procedural code. if you ever want an example look through the gtk source. its about the cleanest c code i've ever seen. but realize that essentially what they did was emulate oop with the tools available in c :D