I joined a foreign-affiliated SIer this year and am working as a Java programmer. Kantai Collection is my hobby, so this article is about trying to understand object-oriented programming by involving Kantai Collection. Kantai Collection You can understand it without knowing this, but if you don't like Kantai Collection, I recommend browser back.
OOP is an abbreviation for Object-Oriented Programming. In other words, object-oriented programming. Procedural programming languages (C, COBOL, BASIC, etc.) describe processes and methods on data, while object-oriented programming languages generate ** objects ** that contain both data and methods.
--Fast and easy to execute --Give a clear structure to the program --Keep Java code in [DRY](https://ja.wikipedia.org/wiki/Don%27t_repeat_yourself#:~:text=Don't%20repeat%20yourself%20(DRY,%E3%81%A7%E3%81%AA%E3%81%84%E3%81%93%E3%81%A8%E3%82%92%E5%BC%B7%E8%AA%BF%E3%81%99%E3%82%8B%E3%80%82) (Don't Repeat Yourself), maintainable, easy to modify and debug —— Allows you to create fully reusable applications with less code and less development time
Classes and objects are two major aspects of object-oriented programming.
The following shows the relationship between classes and objects. The destroyer class has objects called sea breeze, beach breeze, and valley breeze, and the battleship class has objects called Yamato, Kongo, and Musashi.
A class is a template for an object, and an object is the instance (entity) of the class.
When individual objects are created, they inherit all variables and methods from the class. Inheritance means inheriting. Battleship-class objects inherit the method of firing large caliber guns, and destroyers inherit methods such as anti-submarine capabilities. It's like that.
Recommended Posts