Introduction to Object-Oriented Programming -1 Object & Class

Object-Oriented Programming

In this article, we will see what does Object-Oriented Programming — abbr. OOP- means. Many times, we see it in action but do we really know what it actually implies for? Let’s jump right in.

Everything we see around is basically an object and OOP is a model that assumes everything is, well, an “object”.

Maybe these objects have similar properties. But they are completely different objects and they have their own actions. There are behaviors we expect from every object.

So we wrote the objects with properties and methods and explain each one as a schema. We call these schemas a Class.

An object is a real form of class. We can produce a lot of different objects by using variants of properties.

We understood the object and class differences. And now we will see how can create an object using classes.

First of all, we using new Classname words to create a new object by using this class name. In summary, we say create me an object of this class. Then we set this object to a variable. Finally, we have an object and now we can set properties to this object. — I’ll explain why I use this way to set the properties to the object in the future encapsulation article. —We can call the object methods the same as setting the properties.

Why we use empty brackets after the new iPhone words? It’s called an Empty Constructor.

If I want to set my values to the first step, we call this way as a Parameterized Constructor.

Parameterized Constructor

Some software projects can have hundreds of classes. And of course, we can not keep all of these classes in one folder. We should use the design patterns and best practices for project structure.

Full Stack Developer👨🏻‍💻 Camper 🏕️

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store