Hello world. This is Professor Joy and I'm talking about object-oriented programming. Object-oriented programming is a way of looking at the things we deal with in a program As a unit rather than as just variables and functions or procedures. These units are called classes. We use those classes to create objects. Classes are extremely useful in modularizing a system. As we break a system into classes, we can focus on testing and debugging each class, Then use these classes in multiple programs. Once we have created these classes, we can focus on the program that uses those classes. Real life example: When a person gets in a car they should be thinking about where they need to go, and what they're going to do. If they have to think about what makes the car start. And how a combustion engine works, They can't focus on the important aspects of the day. A class is it design or template. That combines attributes and methods. Attributes may also be called properties. These are values such as name, color, height, date, Etc. Methods. May also be called functions or procedures. Attributes are nouns. Methods are verbs. By combining the attributes and methods, a programmer Can use the class without having to think about how the class works. The class is just the design for an object. We must create an instance of the class to have something we can use. An instance of a class is called an object. Just as a blueprint of a house is not something you can live in, you need to create an actual house from the blueprint. The date class- It's in many languages- Has attributes month, day, and year. It has methods to set the date, format the day, Compare it to other dates, get the day of the week, and other useful methods. A date class has methods to make sure The values for month day and year. Are always valid. For instance you can't have a month outside the range 1 to 12. you can't have December 31st. You can't have February 29th unless it's leap year, and so on. An example: A programmer is writing a program to check books out of the library. One of the tasks is to calculate the due date. Which is 14 days from the current date. The due date could be this month, next month, or even next year. A C# programming only has to create an instance of the class. Called today and add 14 days to it. Program work doesn't need to know the details of how the date class works. So here's the code it's called the date time class and we say today is the time right now and so the date time class has that method, Define from the system The date right now. And then we say Due date is today add 14 days to it. And so the programmer doesn't have to think about how that works, all he needs is these two lines of code. He doesn't have to know if it's leap year, Or how many days are in each month, and so on. That's all he has to do. The Button class has attributes such as name, text, color, height, and the XY location. It has methods for clicking it, moving the mouse over it, And others. Programmers create an instance of the button class by putting it on the form or page, then they can change the properties are attributes and write what they want to happen when the button is clicked. Programmer can focus on what the button should do, Not how buttons work. Using object-oriented program has simplified creating a graphical user interface using buttons and other similar objects. A bank account class would have attributes such as name, Account number, It has methods for depositing, withdrawing, opening and closing the account. The opening method creates an instance of the bank account class. The withdrawal method will not let you withdraw more than the balance. The programmer can focus on other parts of the program. A Button and the Date class are often built into the language but sometimes 0:06:09.356,0:06:11.639 you need to create your own class. For instance of programmer is working on tutorials on fractions and he creates a fraction class. The fraction class has two attributes: numerator and denominator. It has methods to reduce a fraction, convert to decimal, and find a common denominator. Once the class has been created and tested, Can be used in other programs. The programmer can now focus on other parts of the program. Classes in classes. A class can contain other classes. For example an appointment class, Could contain a date time class and an address class. A person class could contain a date class for birthday, and an address class. Inheritance: Clowns can be derived from another class. We have created a Person class we don't have to start from scratch to create an Employee class. We can say that an Employee is a Person. Person being the base class. And add pay attributes and methods to calculate pay, give a raise, or to fire the employee. We say that the Employee class is derived from the Person class. Or that the Employee class inherit from the Person class. Polymorphism: Polymorphism means that instances of a class can take different forms. For an example in an employee class, we could have different ways of calculating pay: Hourly workers sales people who get commission and salaried employees. Their pay is all calculated in a different way. . 0:08:17.080,0:08:21.880 A Shape class we would have different methods for finding the area, depending on whether the shape is a triangle, square or circle.