250 likes | 259 Views
Object Oriented Programming. Dr. Ennis-Cole CECS 5100. Conventional Programming. * Unstructured Programming * Procedural Programming * Modular Programming *Object Oriented Programming. Unstructured Programming. 1. One Main Program 2. What is a program ?. Unstructured Programming.
E N D
Object Oriented Programming Dr. Ennis-Cole CECS 5100
Conventional Programming * Unstructured Programming * Procedural Programming * Modular Programming *Object Oriented Programming
Unstructured Programming 1. One Main Program 2. What is a program ?
Unstructured Programming Program: Statements or commands sequentially ordered that modify data and create output which solves a specific problem.
Unstructured Programming 1. Copied the same programming statements to different locations within the program 2. Redundancy often created errors throughout the program
Unstructured Programming Main Program (data)
Procedural Programming Grouped repetitive statements into a single place called a procedure Call statements invoked the procedure Control resumed at the statement after the procedure was called
Procedural Programming Parameters were introduced to communicate between procedures This approach produced more correct code, made testing easier, and reduced the overall program error rate.
Procedural Programming • Main Program • Procedures • Programs became a sequence of calls to procedures • Procedures could be used in different programs
Procedural Programming Main Program (data) Proc A Proc B Proc C Proc D Sub a1 Sub d1 Sub d2
Modular Programming • Procedures with common actions were grouped together into modules • Programs were divided into smaller entities or modules which worked in concert to produce the desired outcome • Separately testable and programmable units made development faster and more efficient
Modular Programming Modules Packaged with data and procedures all grouped based on functionality
Modular Programming • Conservative • Consistent Main Program (data) Module 1 data + data 1 Module 2 data + data 2 Proc 1 Proc 2 Proc 3
Using Data • In each earlier approach, data represents the symbols, numbers, letters or pictures that the program would manipulate • Several types of data were typically by programming languages: int, bool, trees, sets, arrays, lists, float, string
Object Oriented Programming • OOP - a programming technique that relies on reusable software components that can be applied to different types of problems and applications. The programmer makes the machine work in terms of concepts closer to the user’s every day world. • Principle unit - An Object
Objects • Separate Components (buttons, windows, menus, icons) • Self-Contained Entities • Are Unique • Belong to Classes based on its properties • Is said to be an instance of a class • Created within the Visual Environment
Objects • Private data and the collection of procedures that can access that data • Identified by name and state (values and attributes) • A program can be thought of as a collection of objects
Objects • Receive and act on messages. • Respond to predefined external stimuli. • Interact with each other in a set manner. • Have Properties or distinguishing characteristics (size, shape, pressure, strength). • If people are objects, what are some of their distinguishing characteristics ?
Classes • Hierarchy that allows information to be derived about any instance (object) • Mammal • Human • Animal • Herbivorous • Carnivorous • DOG, COW Rover, Betsy
Class • An actual representation of an ADT (abstract data type). • Provides implementation details for the structure and operations of data that will be processed. • A class is defined as all the information needed to create an object of a particular distinction. (Ex: Integer j, k, m; )
Objects Respond to Messages “What message is conveyed here ?”
Messages • Communication between objects • A request for an object to invoke one of its methods • Messages have names & arguments
What Four Programming Approaches Have Been Discussed to date ?
Methods • Perform useful functions: • interpreting user input • calculating • drawing • Are tied to the events to which an object responds • An object invokes a method as a reaction to the receipt of a message
The End • “That’s all folks.”