1 / 21

OBJECT ORIENTED PROGRAMMING overview

OBJECT ORIENTED PROGRAMMING overview. Chapter 1. Introduction. Aims : to establish understanding of basic concepts of Object Oriented Programming (OOP) What will be covered : Procedural Programming vs OOP History of OOP Object Oriented Application basic concept of OOP. Introduction.

phil
Download Presentation

OBJECT ORIENTED PROGRAMMING overview

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OBJECT ORIENTED PROGRAMMING overview Chapter 1

  2. Introduction • Aims: • to establish understanding of basic concepts of Object Oriented Programming (OOP) • What will be covered: • Procedural Programming vs OOP • History of OOP • Object Oriented Application • basic concept of OOP

  3. Introduction • There are two most widely used programming language styles: • Procedural Programming • Object Oriented Programming

  4. Procedural Vs Object Oriented Programming • Procedural programming • also known as structural programming languages • This type of style allows programmers to write program according to a set of steps for solving problems, usually in a top down manner and in chronological order. • It relies on functional decomposition which means the system is broken down into components/ functions/ procedures. • The programming relies heavily on the 3 basic structures: sequence, selection and iteration. • using traditional programming languages e.g. C, Fortran, Cobol etc.

  5. Procedural Vs Object Oriented Programming • Object-oriented programming • The world around us are made up of objects e.g. people, cars, trees, buildings etc • This is used to model a software system as a set of objects interacted with each other. • The Objects represent the system components • Each OO program file must contain at least one class • Some of the programming language used are Java, C++, C#, VB.NET etc.

  6. Procedural Vs Object Oriented Programming Object-Oriented Programmingis VERY different from procedural programming.   Instead of think of "steps/processes" to solving a problem, we need to think about and identify the objectsinvolved in the problem and how they'll interact. Each object is responsible for its own activities and data. OO developer however must still follow the step of understanding the problem and planning the application

  7. Procedural Vs Object Oriented Programming OBJECT ORIENTED APPLICATION PROCEDURAL APPLICATION Class file: variables methods Data Data Application file: Input Output Object creation Class file: variables methods Application file: Variables Methods Input Output Class file: variables methods

  8. Procedural Vs Object Oriented Programming • The previous diagrams shows that • In procedural programming, • all input, output, variables and methods are put in a single file. • This is quite large and difficult to maintain • In Object Oriented Programming, • most variables and methods are organized within separate classes that define different kind of objects. • A separate, smaller application file handles input and output and creates the needed objects. • OO approach produces more modular and organizedapplication

  9. Architecture - Java OO program file e.g. calculateSalary.java Class/es e.g. calculateSalary Method/s e.g. (main) Statements e.g. System.out.println(“Please enter hours worked”)

  10. Object Oriented Approach • Object oriented approach intended to produce systems which are composite, modular constructions, build using abstraction, and organized around the data. • Suitable to solve large and evolving software system. • Most research claimed that OO IS is much easier to maintain compared to the traditional IS.

  11. History of OOP • Object programming was reported to exists in Simula 67 back in 1960s • Simula 67 is developed at the Norwegian Computing Center in Oslo, by Ole-Johan Dahl and Kristen Nygaard. • Simula 67 is used to program Simulation • Influenced from Simula 67, later, the theory of OOP is introduced by smallTalk (Xerox PARC) which further designed it to include the pervasive use of objects and messages as the basis for computation. • Mid 1980s, OOPdominant the programming methodology through C++ (an extension of C Language) • More recently, a number of OOP languages exists such as Visual Basic .NET, C#

  12. Object Oriented Programming • Why is Object Oriented introduced? • Object Oriented Programming is introduced because of the limitation of the procedural programming which are: • programs written in procedural language become complex very quickly (1000s lines of code) if very large system is developed • difficult to test and maintain • often re-implement code unnecessarily (a large system is normally programmed by more than 1 developer

  13. Object Oriented Programming • Object-Oriented programming uses 3 main concepts: • Inheritance – copying the attributes and methods from the base/parent classes • Encapsulation – data hiding (hiding the attributes from the outside world) • Polymorphism – using methods of the same name for a variety of purposes (overriding or overloading)

  14. Object Oriented Terms and Concepts • An object simply represents any object that you may think of in the "real world". • Tangible (like real objects that you can touch): • e.g., a House, a Car, a Person, etc... • Non tangible objects (sometimes harder to identify): • e.g., a BankAccount, Insurance, a Loan, a Vacation, etc...

  15. Object Oriented Terms and Concepts Objects are made up of two "things": • state (a.k.a. attributes/fields/properties + value) • A given set of data which describes the object • e.g., colour, size, amount, name, phoneNumber, etc... • behaviour (a.k.a. methods or functions) • A set of operation that the object can perform • e.g., walk, run, drive, sell, buy, transfer, computeTotal, open, close, etc...

  16. Object Oriented Terms and Concepts Example of Object, state, behaviour Object State Behaviour Person name, age, gender, phone number get the address, change phone number Customer name, address, purchase history make purchase, list items bought, return item BankAccount owner, balance, accountnumber withdraw, deposit, transfer, get balance

  17. Object Oriented Terms and Concepts • An object is a specific item in the class, often referred to an instance/example of a class. • A class is simply a template/mould/blueprint for constructing objects of a specific type. • Before you can use an object in your program, you MUST define the class.   In fact, ALL objects MUST belong to a class of some kind.

  18. Object Oriented Terms and Concepts Class : Fruit Instances of fruit An instance of the Fruit class refers to a specific fruit. These are all objects

  19. Construction of OO Programming • So how do we actually write an Object-Oriented program ? • Identify  the Objects (i.e., Classes) that represent our problem which is to be solved (or simulated) • identify the object characteristics (i.e., state and behaviour) • Identify the inter-relationships between the Objects (i.e., how they interact).

  20. Example Scheduling application • Involves objects such as: • Students • Course • Schedule • Objects attributes • Student – ID, name, gender, dob • Course – dept, number, descr, credit hrs • Schedule – semester, studentID, a number of courses • Object behaviour • Schedule – assign studentID and course

  21. Exercise • Identify 3 objects that might belongs to each of the following classes: • automobile • animal • bankAccount • footballPlayer • mobilePhone

More Related