Object-oriented programming, also referred to as OOP, is a programming paradigm that includes, or relies, on the concept of classes and objects.
The basic entities in object-oriented programming are classes and objects.
Programming isn’t much use if you can’t model real-world scenarios using code, right? This is where object-oriented programming comes.
The basic idea of OOP is to divide a sophisticated program into a number of objects that talk to each other.
Objects in a program frequently represent real-world objects.
It is also possible for objects to serve application logic and have no direct, real-world parallels. They manage things like authentication, templating, request handling, or any of the other myriad features needed for a practical application.
xxxxxxxxxx
Object Oriented Programming or OOP is a programming paradigm
(style of writing code). In OOP is based on concept of "Objects"
to create objects we define classes (blueprint of objects).
OOP is preferred in big projects where multiple developers are working
on same project, as OOP design provides a coding style which is easy
to understand, contribute, safe to share and modify.
xxxxxxxxxx
====The general view of Object Oriented Programming====
Object-Oriented Programming (OOP) is the term used to describe a programming
approach based on objects and classes. The object-oriented paradigm allows us
to organise software as a collection of objects that consist of both data and
behaviour. This is in contrast to conventional functional programming practice
that only loosely connects data and behaviour
xxxxxxxxxx
class Alien { // Name of the class
// The constructor method will take a number of parameters and assign those parameters as properties to the created object.
constructor (name, phrase) {
this.name = name
this.phrase = phrase
this.species = "alien"
}
// These will be the object's methods.
fly = () => console.log("Zzzzzziiiiiinnnnnggggg!!")
sayPhrase = () => console.log(this.phrase)
}
class Bug {
constructor (name, phrase) {
this.name = name
this.phrase = phrase
this.species = "bug"
}
hide = () => console.log("You can't catch me now!")
sayPhrase = () => console.log(this.phrase)
}
class Robot {
constructor (name, phrase) {
this.name = name
this.phrase = phrase
this.species = "robot"
}
transform = () => console.log("Optimus prime!")
sayPhrase = () => console.log(this.phrase)
}