I tried to summarize object orientation in my own way.

Introduction

Nice to meet you. I'm Mackey, a college engineer. This time, I tried to summarize the object-oriented programming that I didn't understand so far in my own way. In addition, the language used this time is Ruby. It's the first Qiita article, so I think there are some strange things, but I don't know.

Premise for reading the article

・ In ruby, all values are objects -Objects can be created from classes -The object belongs to some class ・ Understand the concept of variables

Reference URL

・ Kinocode / Programming learning video YouTuber's [Ruby Super Introductory Course] 13. Class | A class is a collection of "data" and "processing"![Introduction course for programming beginners] https://www.youtube.com/watch?v=E5IX_WLuvcs&list=PLavQwENTsEBUAgSok7Ww4-Q-ZHissbMOv&index=14

This person's explanation is very easy to understand, so please subscribe to the channel.

What is object-oriented in the first place?

I think that one of the barriers that beginners of programming encounter when programming is objects, classes, instances, methods, and so on. So I would like to explain each word to beginners without technical terms.

What is object-oriented in the first place?

What is a class

A class is an image of a blueprint or a skeleton.

What is an instance?

Instance is a term used when you want to emphasize an object created from a class.

What is a method

Class.rb



//Student class generation
class Student

  //The initialize method is a method that is automatically executed when an object is created.
  def initialize(student_name)
    @name = student_name
  end

  //A method to display the average score of math and English
  def average(math,english)
    result = (math + english) / 2
    p @name,result
  end

end

//Create object
a = Student.new("tanaka")

//Execute average method on instance a of student class
a.average(50,30)

Recommended Posts

I tried to summarize object orientation in my own way.
[Must see !!!] I tried to summarize object orientation!
I tried to deepen my understanding of object orientation by n%
[Swift] I already have a lot of information, but I tried to summarize the cast (as, as !, as?) In my own way.
[Personal memo] I tried to study object orientation lightly
I tried to summarize iOS 14 support
I tried to summarize Java learning (1)
I tried to summarize Java 8 now
I tried to summarize the words that I often see in docker-compose.yml
I tried to summarize the methods used
I tried to summarize Java lambda expressions
I tried to summarize the Stream API
What is Docker? I tried to summarize
I tried to make a parent class of a value object in Ruby
I tried to make my own transfer guide using OpenTripPlanner and GTFS
[Ruby] I tried to summarize the methods that frequently appear in paiza
[Java Spring MVC] I want to use DI in my own class
[Ruby] I tried to summarize the methods that frequently appear in paiza ②
I tried to summarize about JVM / garbage collection
I tried to implement polymorphic related in Nogizaka.
I tried to organize the session in Rails
I tried to implement deep learning in Java
I tried to output multiplication table in Java
I tried to build Micra mackerel in 1 hour!
I tried to develop an application in 2 languages
I tried to create Alexa skill in Java
A super beginner has completed the Spring introductory book, so I will summarize it in my own way
I tried to organize the cases used in programming
I tried to summarize the state transition of docker
# 2 [Note] I tried to calculate multiplication tables in Java.
I tried to create a Clova skill in Java
I tried to make a login function in Java
I tried to summarize various link_to used this time
I tried to implement the Euclidean algorithm in Java
~ I tried to learn functional programming in Java now ~
I tried to find out what changed in Java 9
How to use the getter / setter method (in object orientation)
I tried to make an application in 3 months from inexperienced
I tried to summarize the basics of kotlin and java
I tried to summarize the basic grammar of Ruby briefly
I tried to summarize personally useful apps and development tools (development tools)
I tried to convert a string to a LocalDate type in Java
I tried to summarize personally useful apps and development tools (Apps)
I tried using Dapr in Java to facilitate microservice development
I tried to implement a buggy web application in Kotlin
I tried to make a client of RESAS-API in Java
I tried to verify yum-cron
I tried metaprogramming in Java
[java] What I did when comparing Lists in my own class
I tried to create a simple map app in Android Studio
I tried to implement Ajax processing of like function in Rails
I tried to summarize what was asked at the site-java edition-
I tried to illuminate the Christmas tree in a life game
I tried to sort the data in descending order, ascending order / Rails
I tried to write code like a type declaration in Ruby
[Ruby] Tonight, I tried to summarize the loop processing [times, break ...]
Special Lecture on Multi-Scale Simulation: I tried to summarize the 5th
I tried setting Java beginners to use shortcut keys in eclipse
I'm stuck trying to get my own annotations working in Eclipse
Special Lecture on Multi-Scale Simulation: I tried to summarize the 8th
I tried to summarize devise which was difficult at first glance