Object-Oriented Programming (OOP)
gave programmers a new light in the creation of programs, proven to be extreme
useful with the rising popularity of programming languages like Python, Java
and C++. OOP allow us to create objects which simulate a real life object with functions
and data. Objects are implemented in Python using class, including both
built-in modules as well as user created ones; it has attributes in which
programmers could create functions to make the object useful, and use them to
interact with each other with methods such as inheritance and composition. Classes
allow programmers to organize their code much better by grouping methods
together, and simplify a lot of steps for large-scaled projects. Objects are
used whenever they are called, and do nothing else wise, allowing users to
interact with it anytime they want. Instead of affecting the entire program,
any alterations can be changed directly in that specific class.
Although not too fond of the idea
of programming with classes and functions in the beginning, I have really
taking a liking to OOP. My first encounter with it is with Java in my grade 12
computer science class, which is new for me at the time, I wrote my first class
“BankTeller” which simulate the bank, with methods such as deposit, withdraw,
and check balance. At the time, I didn’t really implement a whole class,
instead writing procedurally generated steps with a lot of if statements to
generate a banker step by step with options; but when there’s a bug, it takes a
long time to find the error, and sometimes I even had to change most of my
code. With a properly written “BankTeller” class, I could have just changed the
functions that caused the errors, and saved a lot of time and effort.
No comments:
Post a Comment