Hard to maintain – if we add a new parameter for the
car, we will have to go over all the code base
Many repetitions (like carMake is written 6 times) and
it looks messy easy to make the error (there are errors in last two calls),
this contributes to the low performance.
Business-logic code (the definition of car properties
and the toString() method) is mixed with the client code (the part where
we call toString()), we can not separate them, because client code refers
to the global variables we created (like myCarMake). Thus an inflexible
Easier to modify (if we add a new property for the
car, the myCar.toString() calls in client code don’t need to be changed).
Less repetitions and in general the code looks clearer
once the object is defined, it is really complex to make the error (you just do
myCar.toString()), no parameters passing, no chance to mix them or pass in the
wrong order. Thus a plus in performance.
The business logic is clearly defined and separated
from the client code, client code is not aware of internal structure of the Car object,thus
As shown in
the sample code:
For OOP the
performance can highly be improved compared to Procedural programming as the
complexity of a given program.
This is well
shown in the sample example code, included in this report. Designing the
function to print the car information in OOP is much flexible than in
designing in Object-oriented Programming or Procedural Programming languages,
the developer will need to have a plan for the program before actually writing
any code. Procedural Programming can be a tempting solution for many developers
because it means they can usually jump into coding quicker, but it can be a
time consuming solution later when changes to the code are needed.Additionally
the up-front planning that is involved in Object-oriented Programming can pay
off in the long run when changes or additions are needed and during the
One of the
most important characteristics of procedural programming is that it relies on
procedures that operate on data – these are two separate concepts. In
object-oriented programming, these two concepts are bundled into objects. This
makes it possible to create more complicated behavior with less code. The use
of objects also makes it possible to reuse code. Once you have created an
object with more complex behavior, you can use it anywhere in your code.