Object-Oriented Programming
Context:-
The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function of the class.
So, we can build the real-time big applications by using the classes, methods, access specifiers, access modifiers, hiding data, showing data, extend the additional code with another class
OOP is a type of software design this design will useful for programming approach
And it is well suited for programs that are large, complex, actively updated and well-maintained projects.
How it works:-
A class that contains planning to to-do the work. And it doesn’t consume any space in memory of the machine
After you execute a class it will convert into the object and takes space in memory of the machine
The class structure is for code re-usability means the superclass is allowed to inherit the features of methods and variables of the superclass (parent class).
A feature of objects is an object’s procedures that can access and often modify the data fields of the object with which they are associated
Examples:-
A civil engineer gives a plan of design for building a house on a chart (CLASS). Then the workers will build the real house according to design (OBJECT).
Similarly, a programmer can give the class a logical structure text in a file (CLASS). Then after the system will run on execution and create data in memory according to login given (OBJECT).
Class:-
Class is a text which consists of the logical operations of the object.
And class can be extended with other classes using specific keywords
That class extension is useful for the project without affecting the entire core project.
And it also useful to debug the newly updated classes
The class consists mainly
- Variables
- Methods
The class architecture will like the variables can handle the data
Syntax:
- class<class_name>{
- variable;
- method;
- }
In all object-oriented programming languages fallowing the same structure of the class
- Classes
- Interfaces
Access Specifiers in class:-
Inside of the class, all are class variables
Inside of the method all are method variables
In programming, we can divide the variables and methods with access specifiers
- public
- private
- protected
- Public
- Can access to other classes
- Private
- Will hide the data in the current class itself.
- Protected
- Will show data to the base class and derived-class only except all other classes it will hide
Method:
The main aim of the method is for writing a specific piece of code and returning its output
It’s always possible to build great things with certain blocks with a clear blueprint
Making everything is possible with clear objects
- The method is a part of the class. A class can be full filled with n number of methods
- A method can get the inputs through the parentheses and produces output when it gets called.
- A method is a set of code wizard
Example:-
In mathematics, we have the functions like f(x) = x*x same concept in programming implemented
Simpler a function in the program is a block of code performs a specific task and returns task output
Syntax:
- class<class_name>{
- function <method_name>(inputs){
- //task logic
- //return logic output
- }
- }
Object:
We use a specific keyword for converting class into the object.
After converting into the object all methods and variables will become the properties of the object
So, we could create the unique name of n number of objects with a different name
And also could interact with other objects with unique names
Conclusion:-
- This is about the main theme of object-oriented programming.
- For security purpose, access specifiers and access modifiers are implemented in object-oriented programming
And the architecture of object-oriented programming like the following.
- A class build with piece of code with certain methods, and variables
- All of those pieces of classes will build packages or modules.
- All of these modules or packages will build the entire project.