Presentation is loading. Please wait.

Presentation is loading. Please wait.

OBJECT ORIENTED PROGRAMMING IS IMPORTANT TO UNDERSTANDING HOW COMPUTERS WORK. OOP ORGANIZES DATA INTO “OBJECTS.” OBJECTS MAY HAVE PROPERTIES, ATTRIBUTES,

Similar presentations


Presentation on theme: "OBJECT ORIENTED PROGRAMMING IS IMPORTANT TO UNDERSTANDING HOW COMPUTERS WORK. OOP ORGANIZES DATA INTO “OBJECTS.” OBJECTS MAY HAVE PROPERTIES, ATTRIBUTES,"— Presentation transcript:

1 OBJECT ORIENTED PROGRAMMING IS IMPORTANT TO UNDERSTANDING HOW COMPUTERS WORK. OOP ORGANIZES DATA INTO “OBJECTS.” OBJECTS MAY HAVE PROPERTIES, ATTRIBUTES, VALUES, FUNCTIONS AND METHODS. Object Oriented Programming

2 Object-Oriented programming To talk to a computer, you have to think like a computer. Many people are afraid of this and believe it is mysterious, but it is not as hard as you think. Computers are creations of the human mind, so a computer thinks like we do in some ways. We make computers to help us handle information, like how we make cars to move us around, or houses to live in, or farms to grow food. Computers are one kind of technology, because they extend human ability.

3 Objects in Websites In Websites, typical objects are pictures, boxes, forms, videos and links. The ability to give a computer instructions is powerful and fun for many people, but it takes a lot of study and effort to do it well. If you can do it well, you will be able to help people and they will pay you for your skill.

4 Objects In the human world, we think of objects. Objects could be people places, cars, buildings, food, animals, clothing - basically, anything that exists is an object. Let's say "dog" is an object. When you say, "There’s a dog," a computer thinks "OBJECT: dog."

5 Properties People give objects properties. Properties (sometimes called "attributes") are things like height, weight, speed, color, type, emotions, location, name, date. When you say, “There’s a dog with color,” a computer thinks "OBJECT: dog. PROPERTY: color."

6 Values Properties have values. Values give meaning to properties; a property without a value isn't of much use. Values are things people can see, feel, use or respond to. Values are things like 5 kilograms, 35 miles per hour, blue, good, bad, beautiful, happy, sad, December 17, John. When you say, "There’s a brown dog," a computer thinks, "OBJECT: dog. PROPERTY: color. VALUE: brown."

7 Functions and methods Objects can have actions– things that objects do, or have done to them. When the object carries its action with it, it is called a method. When the action is outside the object, it is called a function. Functions and methods for dogs might be bark, eat, run, sleep, petting, feeding, training, transporting.

8 Change things with functions When you say, "The brown dog barks," a computer thinks, "OBJECT: dog. PROPERTY: color. VALUE: brown. METHOD: bark." Functions and methods can also change properties and values. You can create or delete properties, or change their values. With functions and methods, you can change anything about the dog – give it wings, change its color, make it happy or sad.

9 Classes We can put objects in classes. For example, all dogs have some things in common. So you can put all dogs in the class called “dog” and they all have the same properties: All dogs bark, run, have four legs, have weight, have height and have a tail. Every dog is an instance of the dog class. If you want to make a new dog, you don’t have to write a bunch of properties and values. Just create a new instance of the dog class. Question: If all dogs have the same properties, will they also have the same values?

10 Confusion BUT: Sometimes, properties will seem like objects, methods will seem like objects, objects will seem like values. This can be very confusing, even for people who are good at coding. Do not worry so much about understanding this right now.

11 You’ve been doing this You have been dealing with objects, properties, values and functions for a long time. Have you ever gone to a website and filled out a form? You’re creating the "You" object with properties like “firstName,” “lastName,” "address" and "birthday" and values like "1234 Main St" and "May 12, 1980." When you "submit" the form, the "submit" JavaScript function and PHP hand the form to a database on a server.

12 Create some objects You can give an object any properties you want and sometimes, properties can have many values. Like this: OBJECT: soup PROPERTIES: taste, nutrition, ingredients, country Possible TASTE VALUES: good, bad, salty, sweet Possible INGREDIENTS VALUES: water, meat, spices, vegetables Possible GEOGRAPHIC VALUES: Asian, African, South American, European, Chinese, Mexican, American, German, Ethiopian Possible NUTRITION VALUES: protein, vitamins, fiber

13 Exercises Create a soup object with four properties and at least two values for each property. You can use commas between words, like the example. THINK : Can a soup object have any methods – can the soup do anything ? Not all objects have to have methods. Are there any functions that can do things to the soup ? Imagine a machine that sells soup. What functions might it have in its software ?

14 Another exercise Think of an object. It can be anything you want. Give it two properties and give each property a value. Give the property a method. Do this again.


Download ppt "OBJECT ORIENTED PROGRAMMING IS IMPORTANT TO UNDERSTANDING HOW COMPUTERS WORK. OOP ORGANIZES DATA INTO “OBJECTS.” OBJECTS MAY HAVE PROPERTIES, ATTRIBUTES,"

Similar presentations


Ads by Google