Welcome Guest, Not a member yet? Register   Sign In
Objects: Why are they useful?
#6

[eluser]Beren[/eluser]
Encapsulation is also a very useful feature of OOP - by separating how you ask an object to do something...
i.e.
Code:
$image = new Image('file.gif');
$image->resize(100,75);
$image->save_copy('new_file.gif');
...and the actual process that object takes to perform that action, it enables (amongst many other things) much more scope for the developer to improve and refactor their code whilst isolating that redevelopment from the rest of the app.

Yes this could be achieved by procedural coding certainly, however personally speaking I find that since I switched to writing more OOP style code it makes me a better programmer since each discreet object (and also the methods within those objects) perform specific, clearly defined roles. Great procedural programmers can achieve just as much, but alas I was never one of those! OOP helps (IMHO) provide a 'way' of structuring and thinking about one's code that encourages best (or perhaps 'better') practice.

As with everything in life, your mileage my vary!

I think it also depends on the language, OOP is pretty much the only way to write Ruby since it truly embodies 'everything is an object'. PHP is less so and is pretty well suited to both styles of coding (others may have more/better opinions on this). Some languages like Javascript, which is Prototypal, have been 'made' to be more OOP by the frameworks like mootools and jquery - which is both good and bad in that more people know and understand OOP, but then again the Prototypal approach has it's own strengths (and weaknesses).


Messages In This Thread
Objects: Why are they useful? - by El Forum - 01-22-2008, 02:59 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 03:18 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 03:32 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:02 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:20 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:22 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:31 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:38 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:41 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:49 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:51 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:51 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:52 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 05:01 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 05:06 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 05:19 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 06:55 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 07:15 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 07:23 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 07:23 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 08:15 PM
Objects: Why are they useful? - by El Forum - 01-24-2008, 05:47 PM
Objects: Why are they useful? - by El Forum - 01-24-2008, 05:59 PM
Objects: Why are they useful? - by El Forum - 01-24-2008, 06:34 PM
Objects: Why are they useful? - by El Forum - 01-25-2008, 02:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB