The course is part of this learning path
This course delves into Object-Oriented Programming (OOP), covering its main components, and then putting these into practice by walking you through the creation of an app using OOP.
- Learn about classes and how you can leverage them in your code.
- Learn concepts such as Enum, Inheritance, and Access Levels
- Understand how these can be used to build apps
This course is intended for beginners who want to learn how to build apps using Swift.
To the most out of this course, you should have some basic understanding of programming and computer science in general.
Hi. Within this section, we're going to learn about objected-oriented programming. So, this is a very important concept and we're going to deep dive into it. First of all, we're going to start with classes. Classes are so important and we have seen that before. So, we have worked with classes. In our real controller, we have a class and basically we'll write everything in our class.
So, classes actually have functions, have variables, have events inside of them. And we're going to see what are those in this lecture. And we're going to see what is an objected-oriented programming. So, first of all, what are some elements inside of classes?
We have properties. We have some variables like age, like name. So, we can call these attributes or properties, and this defines some attributes, some options that our classes can have. Like we can have a musician class and we're going to have this in a few lecture and we will have some properties inside of that musician class. So, if we can create an object from that class, we can call this an object or an instance. And this instance or this object can have properties. So, this object, for example, a musician can have an age, can have a name.
So, we can actually create more than one object and we can assign different ages, different names to these each object. So, this is not different than creating a string object or an interior object. But this time, we're going to create our own classes in which we define own properties, own values. So, properties are basically variables that we set. So, this is easy. And also we can have actions inside of classes as well. So, we can have a function to make our musicians sing, for example. So, classes are the bigger part. So, classes are the biggest part actually making up a whole project.
So, this is kind of blueprint of our project, and in this blueprint we can have actions. So, we can make our singers sing, we can make whatever we want. And we can have events as well. For example, defining what will happen if we resume this or defining some other events as well. And we're going to see a lot of examples of classes and if you have heard something like model in programming, basically that's what we're going to do in this section. We're going to create a model and we're going to create some instances of that model and they will have properties, actions.
So, let me tell you what objected-oriented programming is in an analogy, so you would understand it better. So, what was the first programming language that has ever come out? It was C. And C was not an objected-oriented programming language. So, it was kind of a procedural programming language. So, what is the difference between procedural and object-oriented programming? Suppose that you have an agency, a software company. This is our company and inside of this software company we have some workers, we have some employees. So, in the procedural programming, we have this kind of a structure.
First, we tell our employee to do the design, create some design for our app, build some user interfaces. And then we go to same employee and say that, "Okay, now we'll write the code, code our app, and implement the design that you have created before." And then later on, we go on and say that, "Please do the marketing and business arrangements as well." So, find some investors, do some app store optimization so that our app will be visible throughout the app store, and take care of everything from bottom to the top.
So, this will be a procedural programming. Rather in object-oriented programming, we have different employees, we have different classes, different objects. So, first we tell, "Take care of the design." And we go to another employee, another class. We say that please do the coding for us. And then finally we say that the app is ready. Please go find us some investors and take care of marketing. As you might imagine, these three classes, these three people can talk with each other, communicate with each other, but they have no idea what the other person is doing in the real life. So, designer will not know what the programming people are doing, or programming people coders will not know what marketing people are doing.
So, this is kind of synchronized between each other but they are focusing on their jobs. So, this is an example of object-oriented programming. So, as you might imagine, this way is much more efficient than saying, "Please take care of everything in one person. We have some different classes talking with each other, working with each other synchronously but they're only focusing on their job."
So, this is an analogy for understanding object-oriented programming. And of course, we're not going to stop here. We're just going to continue and we'll see how to build our own classes, how to create our own objects, and how to implement all of these information into real apps as well. So, that's what we're going to do within this section. So, let's stop here and continue within the next lecture.
Atil is an instructor at Bogazici University, where he graduated back in 2010. He is also co-founder of Academy Club, which provides training, and Pera Games, which operates in the mobile gaming industry.