1 / 15

Information Technology

Learn the history, concepts, and benefits of Object-Oriented Programming (OOP) in this comprehensive introduction. Explore how OOP addresses the limitations of traditional programming approaches and discover its key elements and advantages. Java is also discussed, along with its applications in various domains.

slorena
Download Presentation

Information Technology

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. Information Technology Topic : Introduction to Object-Oriented Programming (OOP) Hall : Smart Room Date : 16-March-2018 Class : III B.Com.(CA) “A” Section

  2. Introduction to Object-Oriented Programming (OOP) • History • Machine language • Assembly language • Sub-routines and loop (Fortran) • Procedures and recursion (Algol, Pascal, C) • Modules (Modula-2, Ada) • Objects (Simula, Smalltalk, C++,Java)

  3. What are the problems? Not generic What happens if more stacks are needed? What happens if a stack of a different type is needed? Fixed size No effective information hiding mechanism int stack[100]; int top; void init(){ top = -1; } void push(int val){ if (!isFull()){ stack[++top] = val; else error(“stack is full”); } ... Why OOP?

  4. #define MAX 100 typedef struct { int top; int val[MAX]; } STACK; typedef STACK *STACK_PTR; void init(STACK_PTR sp); void push(STACK_PTR sp, int x); int pop(STACK_PTR sp); int isEmpty(STACK_PTR sp); int isFull(STACK_PTR sp); What are the problems? Still not generic What happens if a stack of another type is needed? Fixed size No effective information hiding or data protection Why OOP?

  5. Abstract Data Types (ADT) • ADT = (V,O) • V: a set of values • O: a set of operators • Information hiding • Encapsulation • Modularity

  6. Stack is an ADT class Stack { private LinkedList elms; public Stack() { elms = new LinkedList(); } public void push(Object x) { elms.addFirst(x); } public Object pop() { if (isEmpty()){ throw new RuntimeException("Stack underflow"); } else return elms.removeFirst(); } public boolean isEmpty() { return elms.size()==0; }

  7. Elements of OOP • OOP Programming • Provides abstractions of both operations and data • Classes • A class specifies an abstract data type • A class can be defined based on others (inheritance) • A class defines the variables and behavior common to all objects of a certain kind

  8. Elements of OOP • Objects • An object has its own state • An object’s behavior is determined by its class • Methods • Operations on objects

  9. Elements of OOP • Messages • Objects perform computation by sending messages to each other message: receiver method name parameters return value RECEIVER SENDER

  10. Elements of OOP • Receivers • Messages differ from traditional procedural calls in two very important aspects: • In a message there is a designated receiver that accepts the message • The interpretation of the message may be different, depending upon the receiver

  11. Elements of OOP -- Recursive Design • Every object has its own memory, which stores other objects

  12. Inheritance super-class ParkingMeter subclass or extended class DigitalParkingMeter AnalogParkingMeter

  13. Elements of OOP--Overriding • Subclasses can alter or override information inherited from super-classes Bird NotFlyingBird Penguin

  14. Why is OOP popular? • Hope that it will quickly and easily lead to increased productivity and improved reliability (solve the software crisis) • Hope for easy transition from existing languages • Mimic problem solving in real worlds

  15. Java is not Cure-all • Database • Database programming languages • Artificial intelligence • Lisp, Prolog, Constraint languages • CGI • Perl, Java script, TCL • Many other domain-specific languages

More Related