Object Oriented Questions
Object Oriented Questions
There are many benefits of object-oriented programming, including the fact that it is
concise, organized, and allows for the different objects to work together to create a
program. Classes can be classified as a data type, which allows for an extra organization
feature. OOP is also beneficial because it groups the code into smaller seperate files to be
worked on separately. Classes can be used and called in different lines of code, making it
easier to start a new project. This is because you can use old classes that you have
created.
The behaviours of the what the class does and is for are the methods. These methods are
represented as functions.
Reusing code means to create a class, then extend that class to create a subclass. That
subclass can then be called to the code and reused. This means the programmer does not
have to keep rewriting code that they’ve already written. Going back to subclasses, when
you create a subclass, that subclass inherits all of the class's methods and properties. It
also is able to define other properties or methods.
Reusing code relates to inheritance because the subclasses that allow the programmer to
reuse code, inherits properties and methods of the main class.
Encapsulation and delegation both work together to create an efficient program. Both
concepts main idea to create an efficient program.
They also differ from the fact that delegation uses other responsibilities to achieve specfic
tasks. The class delegates the responsibility of the program, if it is given a task that is
outside of the written responsibility of the code. Encapsulation means that the code has
one area of responsibility.
Encapsulation does one thing, the responsibility it was written for, but delegation is the
opposite. It delegates the responsibilities of the program to other pieces of code.