Object Oriented Programming Flashcards
What is OOP?
In the object-oriented paradigm, the problem is divided into smaller parts called objects, and systems are built around objects. Objects are representations of things that exist in the real world that we wish to model in a computer system. Objects do not share data.
What is Procedural programming?
In the procedural paradigm, the problem is divided into smaller parts called procedures (or functions), and systems are built by combining procedures. .
Define instantiation:
The process of making an instance of an object based on the blue print.
Define class:
The blue print or the definition of an object.
What is encapsulation?
Encapsulation binds together the attributes (data) and the methods (functions and procedures) that manipulate the data. It does this so that the data is protected.
Encapsulation is a form of data hiding. The inner details and workings of the class do not need to be understood by anyone other than the class designer.
What does it mean if a class is self contained and why is it important?
Each class should have no awareness of how it will be used, or of any other parts of a system that it may be part of.
- class can be used in other applications
-You can change the internal workings of any class, as long as the public interface isn’t changed.
How do objects interact?
by passing messages - means that they call each other’s public methods.
What is inheritance?
Inheritance is an OOP technique where child classes are derived from a parent class and inherit all of the attributes and methods from the parent.
uses normal empty arrow.
What is polymorphism?
The ability of a method to exhibit different behaviours based on the object it was invoked on.
An example of polymorphism
Overriding
Why favour composition over inheritance?
can cause unintended consequences if base class is changed.
Difference between aggregation and composition:
Aggregation defines a one-way relationship that specifies a ‘has-a’ relationship between two classes while composition that specifies an ‘is-part-of’ relationship between two classes.
Symbol for aggregation:
empty diamond
Symbol for composition:
Filled in diamond
Define composition:
Composition specifies that an instance of the second object cannot exist separately from its ‘owner’.