Procedural programming deals with strictly solving problems
step by step in a specific way, or procedure.
“An example of good procedural style is a square root function.”
(Stroustrup, 1988, pg. 11 9th paragraph)
Double-sqrt(double
arg)
// the
code for calculating sq root
Void
some_function()
Double
root2-sqrt(2)
To summarize Stroustrup’s definition, you find the best
possible algorithms based on which procedures you want.
Object
Oriented Programming (OOP) seems to be amazing when writing code. In my opinion it seems to be on its own level
above the rest. With OOP you could
literally create any real life scenario in your program. The way it works is by first defining a class
(which is like a blueprint of what an object will be like). From the class you can then create objects
from those classes and actually fine tune them so they are unique and
accurately represent what you are visioning.
An example of OOP could be a card game.
You first start by creating a card class you could then create each
individual card (there are multiple ways of accomplishing this, one might be
creating two subclasses of value and suite).
OOP also allows you to almost effortlessly shuffle and deal those cards
as well.
I’m
pretty sure it’s obvious that I prefer OOP over procedural programming based on
the above text. I am still very new to
programming so I may think differently as I experience each language work on
various tasks, but for now OOP just seems like a no-brainer. Although I prefer OOP, I do think there are
situations in which procedural programming gets the job done, however can’t you
accomplish anything using OOP that you can with procedural?
References
Stroustrup, B.
(1988). What is object-oriented programming? IEEE Software, 5(3), 10-20.
doi:http://dx.doi.org/10.1109/52.2020
0 comments :
Post a Comment