Object Oriented Programming
Procedural
Spaghetti Code!
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?
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![]()
Awaiting that tutorial WP =)
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.![]()
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
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".
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
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"
www.amrosama.com | the unholy methods of javascriptCode:eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
The only thing OOP adds is code reuse whether by generality, easy extension or whatever.
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.Code:<?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");
?>
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)
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks