













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Object-oriented programming (OOP) refers to a type of computer programming (software design) in which programmers define not only the data type of a data structure, but also the types of operations (functions) that can be applied to the data structure.
Typology: Essays (university)
1 / 21
This page cannot be seen from the preview
Don't miss anything!














Introduction to Object Oriented Programming
Instructor Abdul Haseeb Shujja Office hours Mon-Fri 4:00 – 6:00 PM Email [email protected] Moodle Enrollment Key OOP
No cheating allowed….EVER! Do everything yourself Try “googling” the errors/problems you get If you cant find solutions anyway, come to me or email me your code with your problem along with a description of what you have tried so far. Late submissions will result in marks deduction (No Exceptions) 10% every day Want a good grade? PRACTICE
Session 1: Introduction to OOP, Objects and Classes Session 2: C# basics - I Session 3: C# basics - II Session 3: Encapsulation and Abstraction Session 5: Constructors and Destructors Session 6: Inheritance Session 7: Polymorphism Session 8: Association, Aggregation and Composition Session 9: MIDTERM
Object Usually a person, place or thing ( a noun ) Method An action performed by an object ( a verb) Attribute D escription of objects in a class Class A category of similar objects (such as automobiles) Does not hold any values of the object’s attributes
Objects have both data and methods (^) Objects of the same class have the same data elements and methods (^) Objects send and receive messages to invoke actions Key idea in object-oriented programming: The real world can be accurately described as a collection of objects that interact.
(^) Save development time (and cost) by reusing code once an object class is created it can be used in other applications (^) Easier debugging classes can be tested independently reused objects have already been tested
Encapsulation Abstraction Inheritance Polymorphism
Focus only on the important facts about the problem at hand To design, produce, and describe so that it can be easily used without knowing the details of how it works. Analogy: (^) When you drive a car, you don’t have to know how the gasoline and air are mixed and ignited. (^) Instead you only have to know how to use the controls.
The same word or phrase can mean different things in different contexts Analogy: In English, bank can mean side of a river or a place to put money
Five Rules Everything is an object. A program is a set of objects telling each other what to do by sending messages. Each object has its own memory (made up of other objects). Every object has a type. All objects of a specific type can receive the same messages. All object oriented languages generally follow these rules.
Pure Object Oriented Languages: Java C# JavaScript Eiffel Hybrid Languages C++ Objective-C Object-Pascal (Delphi)
First identify its objects. We’ll use the example of a car Then identify what properties these object have in common Engine, color, seats, body, wheels etc. These will be our attributes Now identify the common actions that the objects can perform Accelerate, brake, ignition, switching off, turn etc. These will be the functions/methods of the class. Now, write the class.
class car { public string color{set;get;} public void MyColor() { Console.WriteLine("My color is {0}",color); } } //end class *do not copy and run this code, use the text file provided on LMS instead