Object Oriented Programming (OOP)
Object Oriented Programming (OOP)
Object Oriented Programming is a programming concept that is based on Objects. There are many languages that follow the OOP concept.
Previously, code was written continuously in one block. Hundreds of lines of code were in one block. Then, if errors occur while running that program, it is difficult to find out which line and where the error occurs. Even if you go to update the program, it is difficult to find where you need to change because of a large block.
For these reasons, programmers found a way to program the block into parts. The OOP concept was born as a result. Here, the block is broken into pieces based on objects.
Some Advantages of OOP programming
- Troubleshooting is easier with the OOP language
- Code Reusability
- Productivity
- Data Redundancy
- Code Flexibility
- Solving problems
- Security
There are 3 main blocks in OOP concept.
- An object can be defined as a data field that has unique attributes and behavior.
- A class is a blueprint for creating objects.
- A method is a procedure associated with an object.
- Variables are used to store information to be referenced and manipulated in a computer program.
Standards of OOP
In the OOP, we use a set of regulations to facilitate the future actions of the program. It is convenient for programmers.
- Class name - Class name should start with uppercase letter
class Car {
//code
}
- Method name - All characters are lowercase in method name and have parameters with in brackets.
class Car {
drive() {
//code
}
}
- Variable name - All characters are lowercase in variable name.
class Car {
drive() {
int wheels ;
}
}
- Semi colon ( ; )- Used for donating line end.
class Car {
drive() {
int wheels ;
}
}
- Open curly bracket ({ ) - Starting the block.
class Car {
drive() {
int wheels;
}
}
- Closing curly bracket ( } ) - Ending the block.
class Car {
drive() {
int wheels;
}
}
- Dot operator ( . ) - Used to call operations.
class Car {
drive() {
System . out . print("2023 Mortar Show");
}
}
- Comment ( // and /* .. */) - Used to create a comment.
class Car {
drive() {
// this is one line comment
/* this is multiline comment
this is multiline comment
this is multiline comment
*/
}
}
OOP Objects
Object is a combination of properties and behaviors. In OOP, all are objects (classes, methods, variables).
OOP Class
OOP class sketch used to implement an object at the programming level. In simply word put, template to keep the things we need in order.
Class use properties as variables and behaviors as methods.
Great work 👍..
ReplyDelete