First Lecture -Introduction to Object-oriented programming, Essays (university) of Object Oriented Programming

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)

2017/2018

Uploaded on 09/30/2018

faisal-riaz
faisal-riaz 🇵🇰

2 documents

1 / 21

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Introduction to Object Oriented
Programming
Lecture 1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download First Lecture -Introduction to Object-oriented programming and more Essays (university) Object Oriented Programming in PDF only on Docsity!

Introduction to Object Oriented Programming

Lecture 1

Introduction

Instructor Abdul Haseeb Shujja  Office hours Mon-Fri 4:00 – 6:00 PM  Email[email protected]Moodle Enrollment Key OOP

Rules & tips

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

Course Outline

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

Basic terminology

Object Usually a person, place or thing ( a noun ) Method An action performed by an object ( a verb) AttributeD 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

Object Oriented

Programming

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.

Why OOP?

 (^) 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

Object Oriented Design

Principles

Encapsulation Abstraction Inheritance Polymorphism

Abstraction

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.

Polymorphism

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

Object Oriented

Languages

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.

Object Oriented

Languages

Pure Object Oriented Languages: Java C# JavaScript Eiffel Hybrid Languages C++ Objective-C Object-Pascal (Delphi)

How to identify a class?

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.

Classes: A simple example

(Car)

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