Oops

Object-oriented design started right from the moment computers were invented. Programming was at that place, and programming approaches came into the picture. Programming is basically giving certain instructions to the computer.
At the kickoff of the computing era, programming was usually express to motorcar language programming. Motorcar language ways those sets of instructions that are specific to a particular machine or processor, which are in the form of 0'south and i'southward. These are sequences of bits (0100110…). But it'due south quite difficult to write a plan or develop software in motorcar language.
It's actually impossible to develop software used in today's scenarios with sequences of bits. This was the master reason programmers moved on to the next generation of programming languages, developing assembly languages, which were most enough to the English language to easily sympathize. These assembly languages were used in microprocessors. With the invention of the microprocessor, assembly languages flourished and ruled over the manufacture, just information technology was not enough. Again, programmers came up with something new, i.e., structured and procedural programming.

Structured Programming –
The basic principle of the structured programming approach is to separate a programme into functions and modules. The use of modules and functions makes the program more understandable and readable. It helps to write cleaner code and to maintain control over the functions and modules. This approach gives importance to functions rather than data. Information technology focuses on the evolution of large software applications, for example, C was used for modern operating system development. The programming languages: PASCAL (introduced by Niklaus Wirth) and C (introduced by Dennis Ritchie) follow this approach.
Procedural Programming Approach –
This approach is also known as the pinnacle-down arroyo. In this arroyo, a plan is divided into functions that perform specific tasks. This arroyo is mainly used for medium-sized applications. Information is global, and all the functions can access global data. The bones drawback of the procedural programming arroyo is that data is non secured because data is global and can be accessed by any role. Program command menses is achieved through function calls and goto statements. The programming languages: FORTRAN (developed past IBM) and COBOL (developed by Dr. Grace Murray Hopper) follow this approach.
These programming constructs were adult in the late 1970s and 1980s. There were still some issues with these languages, though they fulfilled the criteria of well-structured programs, software, etc. They were not as structured as the requirements were at that time. They seem to be over-generalized and don't correlate with real-time applications.
To solve such kinds of problems, OOP, an object-oriented approach was developed equally a solution.

The Object-Oriented Programming (OOP) Arroyo –
The OOP concept was basically designed to overcome the drawback of the above programming methodologies, which were non and so close to existent-world applications. The demand was increased, just still, conventional methods were used. This new approach brought a revolution in the programming methodology field.
Object-oriented programming (OOP) is nix merely that which allows the writing of programs with the help of sure classes and real-time objects. We can say that this approach is very close to the real-world and its applications because the state and behaviour of these classes and objects are almost the same equally real-world objects.
Allow's go deeper into the general concepts of OOP, which are given below:
What Are Class & Object?
It is the basic concept of OOP; an extended concept of the structure used in C. It is an abstract and user-divers data type. Information technology consists of several variables and functions. The chief purpose of the form is to shop data and data. The members of a form define the behaviour of the form. A course is the blueprint of the object, but also, we can say the implementation of the course is the object. The class is non visible to the world, but the object is.

CPP

Course car

{

int car_id;

char colour[4];

bladder engine_no;

double distance;

void distance_travelled();

float petrol_used();

char music_player();

void display();

}

Here, the class motorcar has properties car_id, colour, engine_no, and distance. It resembles the existent-world car that has the same specifications, which tin exist declared public (visible to everyone exterior the class), protected, and private (visible to none). Also, there are some methods such as distance_travelled(), petrol_used(), music_player() and display(). In the code given below, the auto is a class and c1 is an object of the car.

CPP

#include <iostream>

using namespace std;

class machine {

public :

int car_id;

double distance;

void distance_travelled();

void brandish( int a, int b)

{

cout << "car id is=\t" << a << "\ndistance travelled =\t" << b + 5;

}

};

int master()

{

car c1;

c1.car_id = 321;

c1.distance = 12;

c1.display(321, 12);

render 0;

}

Data Brainchild –
Abstraction refers to the act of representing important and special features without including the groundwork details or explanation about that feature. Information abstraction simplifies database pattern.

  1. Physical Level:
    It describes how the records are stored, which are often hidden from the user. It can be described with the phrase, "block of storage."
  2. Logical Level:
    Information technology describes data stored in the database and the relationships between the data. The programmers generally work at this level as they are aware of the functions needed to maintain the relationships between the information.
  3. View Level:
    Awarding programs hide details of data types and information for security purposes. This level is generally implemented with the help of GUI, and details that are meant for the user are shown.

Encapsulation –
Encapsulation is one of the fundamental concepts in object-oriented programming (OOP). It describes the idea of wrapping data and the methods that work on data within one unit, e.g., a class in Java. This concept is ofttimes used to hide the internal land representation of an object from the outside.
Inheritance –
Inheritance is the power of one grade to inherit capabilities or properties of another class, chosen the parent grade. When nosotros write a class, nosotros inherit properties from other classes. So when we create a class, we do not demand to write all the properties and functions again and again, as these can be inherited from another class that possesses it. Inheritance allows the user to reuse the code whenever possible and reduce its redundancy.

Java

import java.io.*;

course GFG {

public static void main(String[] args)

{

System.out.println( "GfG!" );

Dog domestic dog = new Dog();

dog.name = "Balderdash dog" ;

dog.color = "Brown" ;

dog.bark();

domestic dog.run();

Cat cat = new True cat();

cat.name = "Rag doll" ;

cat.design = "White and slight brown" ;

cat.meow();

cat.run();

Beast animal = new Animal();

animal.name = "My favourite pets" ;

animal.run();

}

}

class Creature {

Cord name;

public void run()

{

System.out.println( "Animate being is running!" );

}

}

class Domestic dog extends Animal {

Cord colour;

public void bark()

{

System.out.println(name + " Wooh ! Wooh !"

+ "I am of colour " + colour);

}

}

class Cat extends Animal {

String blueprint;

public void meow()

{

System.out.println(proper noun + " Meow ! Meow !"

+ "I am of colour " + pattern);

}

}

Polymorphism –
Polymorphism is the power of data to be processed in more than than one form. It allows the operation of the same task in various ways. Information technology consists of method overloading and method overriding, i.e., writing the method once and performing a number of tasks using the aforementioned method name.

CPP

#include <iostream>

using namespace std;

void output( bladder );

void output( int );

void output( int , float );

int main()

{

cout << "\nGfG!\n" ;

int a = 23;

bladder b = 2.three;

output(a);

output(b);

output(a, b);

return 0;

}

void output( int var)

{

cout << "Integer number:\t" << var << endl;

}

void output( float var)

{

cout << "Float number:\t" << var << endl;

}

void output( int var1, bladder var2)

{

cout << "Integer number:\t" << var1;

cout << " and float number:" << var2;

}

Some important points to know nigh OOP:

  1. OOP treats data as a critical element.
  2. Emphasis is on data rather than procedure.
  3. Decomposition of the problem into simpler modules.
  4. Doesn't let information to freely flow in the unabridged system, ie localized control flow.
  5. Data is protected from external functions.

Advantages of OOPs –

  • It models the real world very well.
  • With OOP, programs are like shooting fish in a barrel to understand and maintain.
  • OOP offers code reusability. Already created classes can be reused without having to write them once more.
  • OOP facilitates the quick development of programs where parallel development of classes is possible.
  • With OOP, programs are easier to exam, manage and debug.

Disadvantages of OOP –

  • With OOP, classes sometimes tend to be over-generalized.
  • The relations amongst classes become superficial at times.
  • The OOP design is tricky and requires appropriate knowledge. Also, ane needs to practice proper planning and design for OOP programming.
  • To program with OOP, the developer needs proper skills such as blueprint, programming, and thinking in terms of objects and classes, etc.

holtlabley.blogspot.com

Source: https://www.geeksforgeeks.org/oops-object-oriented-design/

0 Response to "Oops"

Enviar um comentário

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel