OOPS FULL FROM. OPPS WHAT IS FULLFORM

OOPS FULL FROM. OPPS IS WHAT IS FULLFORM

Object-Oriented Programming System is the full form of OOPS.

O=Object

O=Oriented

P=Programming

S=System.

What is Object-Oriented Programming System OOPS ?

When I read the explanation of object-oriented programming in books and the Web, it says, “Object-oriented is the idea of ​​capturing the behavior of a system as an interaction between objects.” This is strangely difficult to explain, and I think that there are many people who get ready.

However, object-oriented programming is “a model of a real-world object as it is” so that it is easy for humans to understand, and it should be easy to understand.

Things in the real world are, for example, “company,” “employee,” “airplane,” … “cabbage,” “radish,” and so on. In other words, this thing can be called an object.

Difference between “object” and “class”

Don’t confuse “object” with “class”, let’s briefly explain the difference.

A class is like a blueprint. A concept defined to create an object.

For example, home appliances such as “TVs”, “air conditioners”, and “vacuum cleaners” have different types but have a commonality (concept) as “home appliances”. A class is a collection of these commonalities (in the above example, home appliances are a class).

And what is materialized based on the blueprint is an object (in the above example, a TV, an air conditioner, and a vacuum cleaner can be said to be objects). Materialization refers to instantiating a class (a state in which the computer has allocated memory).

Let’s take a look at the class diagram and the object diagram. Both are the basic diagrams of UML, and the class diagram is a diagram showing the structure and interrelationship of abstract representation classes. Object diagrams, on the other hand, are diagrams that show the relationships between objects by instantiating classes. By comparing these two figures, I think it will be easier to imagine the difference between a class and an object.

As an example, in the case of “human” and “home appliances”, since humans own home appliances, the class diagram is as follows.

Object-oriented programming OOPS 

Coding with the class diagram above, that is, object-oriented programming OOPS that incorporates polymorphism, is as follows.

[Yamada.java]

public class Yamada {private Foreigner foreigner;

public Yamada(Foreigner foreigner) {this.foreigner = foreigner;

}

}

    public void greet() {

        foreigner.greet();

    }

}

[Foreigner.java]

public abstract class Foreigner {

    public abstract void greet();

}

[Chinese.java]

public class Chinese extends Foreigner {

    @Override

    public void greet() {

        System.out.println(“ニーハオ”);

    }

}

[American.java]

public class American extends Foreigner {

    @Override

    public void greet() {

        System.out.println(“Hello”);

    }

}

[French.java]

public class French extends Foreigner {

@Override

public void greet() {

System.out.println(“Bonjour”);

}

}

The Yamada class executes a greeting (greet () method) to the Foreigner type object received as an argument of the constructor. A constructor is a method that is called when an object is created to initialize its contents.

Incorporating polymorphism, the Yamada class doesn’t really know if an object of type Foreigner is Chinese, American, or French.

This “don’t know” is the essence of polymorphism that behaves differently depending on the actual condition of the received object (if you pass a Chinese class object, you say “Nihao”, and if you pass an American class object, you say “Hello”. If you pass an object of French class, you will say “Bonjour”).

By the way, in non-object-oriented programming like procedural programming, it looks like this: Procedural programming is programming in which processing is executed in order from the program, considering how the computer works to improve processing efficiency. Instead of programming in a way that is easy for humans to understand like object-oriented programming, we prioritize the emphasis on computer processing efficiency.

[Foreigner.java]

public class Foreigner {

    public void greet(String foreigner) {

        if (“Chinese”.equals(foreigner)) {

            System.out.println(“ニーハオ”);

        } else if (“American”.equals(foreigner)) {

            System.out.println(“Hello”);

        } else if (“French”.equals(foreigner)) {

            System.out.println(“Bonjour”);

        }

    }

}

The Chinese, American, and French classes are gone, only the Foreigner class. It is a coding that branches one class with an if statement.

Of course, this still works the same as programming made in object-oriented programming, but if you add another foreigner, for example, in object-oriented programming you just add a new class that inherits the Foreigner class ( If you add a new class without modifying the existing class or source code at all), you have to modify the existing source code because there is an if statement in procedural programming (add more else if) ..

Since this example is a sample, it is a simple if statement, but in normal business it will be a more complicated branch code. Complex branching code is not only time-consuming to modify, but it may also cause it to stop working properly.

In normal business, there are many situations where you need to modify the system, such as changing specifications, adding functions, and dealing with failures, so please consider object-oriented programming.

In conclusion

How was it? This time, I explained the classes and objects required for object orientation, inheritance, encapsulation, and polymorphism.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top