Ruby 101 (Part 1): Object-Oriented Programming

in #technology6 years ago (edited)

Would you like to learn programming but don’t know where to start? Ruby is widely regarded as one of the best programming languages for beginners. It is an object-oriented language. This post (which is part one in a series of posts on Ruby programming) will explain the basic fundamentals of object-oriented programming. Please click here to read the introduction to this series.

Classes and Objects


bronze-610837_1920_a01 - Copy.jpg
What do programming languages like Ruby, Java, PHP and Python all have in common? They are all object-oriented, as are several other popular programming languages. Ever since around the 1990s, object-oriented programming has been one of the most common types of programming.

This style of programming is very much a product of how modern humans tend to perceive reality. Much of modern philosophy happens to be inspired by something called Platonic realism, which can be regarded as an ancient ancestor to object-oriented programming.

We humans have a tendency to divide concepts and phenomena into categories, like things and ideas. In a way, ideas are like the blueprints for things.

An example of this would be human beings in the general sense as it relates to specific people. You can approach a single individual with the knowledge that they belong to the broader set of humanity. Then, you can request they tell you their name in order to identify them as a unique part of that broader set.

This is the same approach as object-oriented programming. In these types of programming languages, general phenomena are known as classes and their specific manifestations are called objects.

As a programmer, you would define classes (like a class user and a class post) and then create actual instances of these classes: an actual user with a display name, password and blog posts; or a unique blog post with specific words and pictures. You would likely also imbue users (as a class) with the ability to perform specific actions, and would likewise imbue posts (as a class) with certain features.

In summation, if classes are like ideas, then objects are like the actual manifestations of those ideas.

Ruby, like other object-oriented programming languages, has certain classes already baked into it. These include strings (which are basically lines of text) and numbers. These allow you, the Ruby programmer, to create things like text groups as well as mathematical calculations in an object-oriented manner.

Conclusion


This is part one of a series of posts on Ruby programming. The next post in this series will cover the subject of variables.

This post is licensed under the Creative Commons Attribution-ShareAlike 2.0 Generic license (CC BY-SA 2.0 1920px-CC-BY-SA_icon_a02 - Copy.jpg) (source).

Coin Marketplace

STEEM 0.18
TRX 0.13
JST 0.028
BTC 57292.40
ETH 3073.43
USDT 1.00
SBD 2.32