What is OOP? Flashcards
What is OOP?
It is aprogramming paradigmin which we think about a problem in terms of objects, bundles combining both state and behavior.
What is Instantiation?
Instantiationis the process of creating a new instance object
What is encapsulation?
encapsulation describes the idea of bundling or combining the data and the operations that work on that data into a single entity, e.g., an object. It may also refer to the limiting of direct access to some of that data, such as an object’s components.
how do you use compact method syntax?
let raceCar = {
make: ‘BMW’,
fuelLevel: 0.5,
engineOn: false,
startEngine() {
raceCar.engineOn = true;
},
}
You can omit the:and thefunctionkeyword and use parentheses to denote a method.
What are collaborators?
Objects that help provide state within another object are calledcollaborator objects, or more simply,collaborators.Collaborator objects play an important role in object-oriented design; they represent the connections between the different classes in your program
We say that two objects have a collaborator relationship if one of them is part of the state of the other.
Define a factory function for a car
function createCar(make, fuelLevel, engineOn) {
return {
make: make,
fuelLevel: fuelLevel,
engineOn: engineOn,
startEngine() { this.engineOn = true; }, }
What is factory Shorthand?
function createBook(title, author) {
return {
title, // same as title: title,
author, // same as author: author,
getDescription: function() { return `${this.title} was written by ${this.author}.`; }, }; }