Lecture03-Object_Oriented_Programming

Lecture03-Object_Oriented_Programming - Introduction to...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Introduction to Object-Oriented Programming Computer Programming II 1 Lecture 3 2 l To understand the differences between Procedural Programming and Object-Oriented Paradigm l To understand how to c ategorize similar objects l To understand how to c ategorize objects by Composition l To understand how to construct Unified Modeling Language Class Diagram l To understand and identify o bject behaviors l To understand and identify the 4 principles of Object-Oriented Programming Learning Objectives 3 Procedural Programming l In Procedural Programming , a problem is associated with a procedures ( ++) - function in C top-down . design l The idea is to design a program to solve a problem by concentrating on the procedures first and data second . l The main function coordinates calls to procedures and hands over appropriate data as parameters. l C is an example of procedural programming languages. l C++ in TCP1231 is taught as a procedural programming language. Main Program Data Function1 Function2 Function3 4 Problems with Procedural Programming Unrestricted access to global data and procedures. Poor modeling of the real world (data and procedures are separated). Not the way that humans naturally think about a situation. Poor code reusability . #include <iostream> using namespace std; void procedure1 (int& a) { a += 1; } void procedure2 (int& a) { a += 2; } int main() { int data1 = 111; procedure1 (data1); procedure2 (data1); int data2 = 100; procedure1 (data2); procedure2 (data2); cout << data1 << endl << data2; } Why Object-Oriented Programming? l Solution to problems of procedural programming l Restrict access to data and procedures (through access privilege, discussed later). l Better modeling of real world objects. Data and procedures are combined in a single unit....
View Full Document

Page1 / 22

Lecture03-Object_Oriented_Programming - Introduction to...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online