Which do you prefer, Object Oriented Programming or Procedural? Why?
I prefer OOP. I like the ability to reuse code and the idea of a class makes more sense to me. Procedural code also has a bad habit of turning into spaghetti code.
Some project I develop in PHP, it makes more sense to use Procedural style, however. For larger projects I feel that OOP is critical in order to develop code that is easily expandable.
What about you?
OOP vs Procedural
Started by
Guest_Jordan_*
, Jun 22 2009 09:43 AM
38 replies to this topic
#1
Guest_Jordan_*
Posted 22 June 2009 - 09:43 AM
Guest_Jordan_*
|
|
|
#2
Posted 22 June 2009 - 12:06 PM
I think it's something of a false distinction. OOP Methods are generally procedural, for example. See my upcoming OOP tutorial (not yet released) for more ideas :)
#3
Posted 22 June 2009 - 12:26 PM
Awaiting that tutorial WP =)
#4
Posted 22 June 2009 - 01:47 PM
OOP is my favourite, I think. It seems to be a great tool to solve problems in a logical and clear way. Yet, I wouldn't turn down procedural programming. OOP can be a bit overkill at times.
Spaghetti-code, on the other hand, is absolutely awful. I've done it, and it is a nightmare both to maintain and expand. :eek:
Spaghetti-code, on the other hand, is absolutely awful. I've done it, and it is a nightmare both to maintain and expand. :eek:
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
#5
Posted 22 June 2009 - 02:26 PM
Objects
I like the idea of being able to reuse code as well. Lately I've found a use for object inheritance and it makes programs so easy to maintain. I don't know if procedural code can be written in a way that would be any easier to maintain. I haven't written much code that is "procedural".
I like the idea of being able to reuse code as well. Lately I've found a use for object inheritance and it makes programs so easy to maintain. I don't know if procedural code can be written in a way that would be any easier to maintain. I haven't written much code that is "procedural".
#6
Posted 23 June 2009 - 05:15 AM
well, i really like OOP
but i find myself coding in Procedural style, specially in PHP , i mostly write set of related functions in a php file and include that file when i need them. im currently trying to be OOP person its seems easy when people talk about funny objects like "human" have hands and legs as private variables blah blah blah.... but in reality i find it hard to do a class for actual stuff
but i find myself coding in Procedural style, specially in PHP , i mostly write set of related functions in a php file and include that file when i need them. im currently trying to be OOP person its seems easy when people talk about funny objects like "human" have hands and legs as private variables blah blah blah.... but in reality i find it hard to do a class for actual stuff
yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
www.amrosama.com | the unholy methods of javascript
#7
Posted 23 June 2009 - 06:44 AM
The only thing OOP adds is code reuse whether by generality, easy extension or whatever.
#8
Posted 23 June 2009 - 08:20 PM
OOP is great. What you can do in three lines of procedural code, I can do in fifty lines of OOP.
One of the problems many people face when it comes to object oriented programming is the whole notion of an object. Many inexperienced programmers will get carried away and represent an entity as an object when there is no need to (like the exaggerated example above). A few months ago I was a strong advocate of OOP, not because you can use objects, but because of design patterns and the beautiful architectures you can create. However, as WingedPanther pointed out these patterns and architectures can just as easily be implemented procedurally. That being said, I don't prefer either. I use what is right for the job.
<?php
interface greeting {
public function hello();
}
class hello implements greeting {
public function hello() {
return "Hello ";
}
public function __toString() {
return $this->hello();
}
}
class say {
private $a;
public function say($a) {
$this->a = $a;
return $a;
}
public function __toString() {
return $this->a;
}
}
class expression {
public function __construct( greeting $a, say $b, $c ) {
echo $a . $b;
switch($c) {
case "exclamation":
echo "!";
break;
default:
echo ".";
}
}
}
new expression(new hello(), new say("World"), "exclamation");
?>
One of the problems many people face when it comes to object oriented programming is the whole notion of an object. Many inexperienced programmers will get carried away and represent an entity as an object when there is no need to (like the exaggerated example above). A few months ago I was a strong advocate of OOP, not because you can use objects, but because of design patterns and the beautiful architectures you can create. However, as WingedPanther pointed out these patterns and architectures can just as easily be implemented procedurally. That being said, I don't prefer either. I use what is right for the job.
#9
Posted 29 June 2009 - 01:52 PM
As I'm teaching myself programming, I really like the concept of OOP so I voted for that but at the moment, I mostly do procedural. However, as I'm dreaming up more and more complex programs, I can totally see the power of OOP.
But even if you love OOP, It seems to me though that procedural programming has a place as OOP can be a bit overkill as some others have pointed out (loved your example John :lol:)
But even if you love OOP, It seems to me though that procedural programming has a place as OOP can be a bit overkill as some others have pointed out (loved your example John :lol:)
#10
Posted 30 June 2009 - 11:25 AM
OOP is definitely the way to go. Code re-use is a major thing for me. If I can write a method only once and use it in multiple places, that means less work for me. :)
-CDG10620
Software Developer
Software Developer
#11
Posted 30 June 2009 - 11:49 AM
I do procedreal and than use includes so that I can reuse the procedral code. I never took the time to learn OOP and procedral works just fine for me so I will stick with that until i get a job and they fource me into OOP
#12
Posted 30 June 2009 - 05:19 PM
Why is it that people assume OOP = reusable, but procedural = forced recode?


Sign In
Create Account

Back to top











