CS-3333R Object Oriented Technology
Object Oriented Programming in C++
Lafore, Robert
Chapter 1 The Big Picture
Why Do We Need Object-Oriented Programming
Procedural Languages
C, Pascal, COBOL, these are all procedural languages
In procedural languages each line tells computer to do something
Works well for small programs
Division into functions
As programs become larger they become harder to understand
Functions were developed
Grouping functions together in a separate entity is called a module
Problems with Structured Programming
Large Programs become complex
Functions have unrestricted access to global data
Unrelated functions and data provide poor models of the real world
Unrestricted Access
Two types of data
Local
inside functions
used only by those functions
Global
Accessed by any function
Leads to potential connections between functions and data
Difficult to conceptualize
Difficult to modify
Real World Modeling
Attributes - (characteristics)
Equivalent to data in person (blue eyes)
have a specific value
Behaviour
How some things respond to stimulus
Like a function, it does what it is told to do.
The Object-Oriented Approach
Create a unit that contains data and functions to manipulate data
Only way to access data is through object functions
Data that does not need to be changed is hidden
An Analogy
Think of objects as departments in company
Each department controls its own data
One department gets data from another department by going through proper channels
OOP: An Approach to Organization
C+ statements look the same as procedural language statements and Object-Oriented Programming statements
Only when they are viewed in context can one tell which they are
Characteristics of Object-Oriented Languages
Objects
Classes
a description of a number of similar objects
An object is called and instance of a class
Inheritance
In natural life we group things together because they are similar
A bus and a car do not look the same but they are both vehicles, maybe cause one characteristics is wheels
In OOP we have a base class that we reuse and they are called derived classes.
Derived classes inherit their information the base class and add some of their own..(bus has lots of seats, car has limited amount, but vehicles has wheels and seats)
Reusability
Creating New Data Types
We can create types to match what we need to do
We can send the information to the class that we create
Polymorphism and Overloading
We can define what normal operators do while in the the class (overloading)
We can use functions and operators in different ways (Polymorphism)
C++ and C
Is a subset of C
Originally called C with classes
Laying the Groundwork
The Unified Modeling Language (UML)
UML provides way to visualize higher-level organization of programs
Programmer does not have to get caught up in details of actual code.
Important part of UML is diagrams
Class diagrams about how the classes relate
Sequence diagrams show how classes communicate
Summary
Questions
No comments:
Post a Comment