G 54 PRG Programming Lecture 19 Object Oriented

G 54 PRG Programming Lecture 19 Object Oriented Theory I Amadeo Ascó Adam Moore 1

Previously • File & Streams – Read – Write • Parsing Amadeo Ascó , Adam Moore 2

Overview • Programming Methodologies – Unstructured Programming – Procedural Programming – Modular Programming • Properties of Modular Programming – Object Oriented Programming • Object Oriented Languages • Objects Amadeo Ascó , Adam Moore 3

Programming Methodologies • • Unstructured Programming Procedural Programming Modular Programming Object Oriented Programming Amadeo Ascó , Adam Moore 4

Unstructured Programming • The main program consists of statements that directly operates on global data (i. e. data that is always available). Program Main Program Data Amadeo Ascó , Adam Moore 5

Procedural Programming • Sequences of statements are combined into one place called a procedure. This can then be invoked as often as needed by the main program. Program Main Program Procedure Amadeo Ascó , Adam Moore 6

Modular Programming • Procedures are grouped into modules or libraries. Program Main Program Module 1 Procedure 1 Module 2 Procedure 3 Amadeo Ascó , Adam Moore 7

Properties of Modular Programming • Programs consist of several (sometimes many) interacting parts. • Libraries can be re-used. • Each module can have its own data, and can manage its own internal state. • Each module exists once in a program, and has a single state. • Management of the state of a module can become complex. Amadeo Ascó , Adam Moore 8

Object Oriented Programming • OO programs consist of a web of interacting objects - each with their own state. • Each object is responsible for initialising and destroying itself correctly. • This addresses the complexities of modular programming. • Objects have other attributes that greatly add to the power of manipulating them. Amadeo Ascó , Adam Moore 9

Object Oriented Languages • Pure OO languages – Smalltalk – Java • Impure OO languages – C++ – PERL – Pascal/Delphi • Mixed paradigm languages – Visual Basic – Java. Script Amadeo Ascó , Adam Moore 10

Objects • The world is full of objects. • OO programming was originally developed for the creation of simulations. • Because programs ultimately interact with the real world, many (the vast majority) of programming problems can be solved by mapping program code to “objects” that mirror real world objects. Amadeo Ascó , Adam Moore 11
- Slides: 11