Object Oriented Programming (OOP) is a method of programming
based on a hierarchy of classes that utilizes objects rather than just the
functions and procedures. In terms of OOP, an “object” refers to a particular
instance of a class. An object can call on functions or methods of the class
the object is an instance of. Using
object oriented programming, coding repetition can be reduced. Rather than
writing coding repetitively one object after another, a class can be created,
and the instances can be used to store the values. This style of programming also
makes the codes easier to maintain because changes can be made within the
object’s class.
So far for this week, we’ve focussed on stacks, raising
exception, and especially inheritance. In object oriented programming, inheritance
allows a class (base class) to transfer its attribute onto another class
(subclass). In addition, a subclass can override data and methods from the base
class. This feature allows programmers to extend or modify codes using the
created subclass without changing the base class. For instance if I have
already created a class A, then allow B to inherit from A allow B to gain
access to any method that is in A that is not defined in B. If B contains any
method that happens to share the same name with a method from A, then we consider
B has overridden that method whether we want to extend on top of the original
method or not. Using OOP creating a stack, or raising an exception can be
achieved by writing their individual classes. This means inheritance would
applicable once a base class is created as I have seen from my lectures.
Overall, starting off a semester by learning about object
oriented programming not only was it fun, but it also helped me to refresh my memory on the concepts I learn from csc108 while learning new concepts with respect to
programming.
No comments:
Post a Comment