Introduction to Object Oriented Programming Software Crisis Software
Introduction to Object Oriented Programming Ø Software Crisis Ø Software Evolution ØDifference between structural programming and OOP Ø Basic Concepts of OOPs Ø Benefits & Applications of OOPs PVG's College of Engineering, Nashik 1
Software Crisis Software crisis : Software crisis is a term used in the early days of computing science for the difficulty of writing useful and efficient computer programs in the required time The following issued need to be addressed to face the software crisis: • How to represent real-life entities of problems in system design? • How to design system with open interfaces? • How to ensure reusability and extensibility of modules? • How to develop modules that are tolerant of any changes in future? • How to improve software productivity and decrease software cost? • How to improve the quality of software? • How to manage time schedules? PVG's College of Engineering, Nashik 2
STRUCTURED vs. OO PROGRAMMING STRUCTURED PROGRAMMING: MAIN PROGRAM FUNCTION 1 FUNCTION 4 FUNCTION 2 GLOBAL DATA FUNCTION 3 FUNCTION 5 PVG's College of Engineering, Nashik 3
Structured Programming • Using function • Function & program is divided into modules • Every module has its own data and function which can be called by other modules. PVG's College of Engineering, Nashik 4
OBJECT ORIENTED PROGRAMMING Object 2 Object 1 Data Function Object 3 Data Function PVG's College of Engineering, Nashik 5
OBJECT ORIENTED PROGRAMMING Objects have both data and methods Objects of the same class have the same data elements and methods Objects send and receive messages to invoke actions Key idea in object-oriented: The real world can be accurately described as a collection of objects that interact. PVG's College of Engineering, Nashik 6
Basic terminology 1. Object • - usually a person, place or thing (a noun) 2. Method • - an action performed by an object (a verb) 3. Attribute • - description of objects in a class 4. Class • - a category of similar objects (such as automobiles) • - does not hold any values of the object’s attributes PVG's College of Engineering, Nashik 7
Example for attributes and methods Attributes: ◦ ◦ ◦ ◦ manufacturer’s name model name year made color number of doors size of engine etc. Methods: ◦ Define data items (specify manufacturer’s name, model, year, etc. ) ◦ Change a data item (color, engine, etc. ) ◦ Display data items ◦ Calculate cost ◦ etc. PVG's College of Engineering, Nashik 8
Why OOP? • Save development time (and cost) by reusing code once an object class is created it can be used in other applications. • Easier debugging classes can be tested independently reused objects have already been tested PVG's College of Engineering, Nashik 9
Design Principles of OOP Four main design principles of Object-Oriented Programming(OOP): Encapsulation Abstraction Polymorphism Inheritance PVG's College of Engineering, Nashik 10
Encapsulation Also known as data hiding Only object’s methods can modify information in the object. Analogy: ATM machine can only update accounts of one person or object only. PVG's College of Engineering, Nashik 11
Abstraction Focus only on the important facts about the problem at hand to design, produce, and describe so that it can be easily used without knowing the details of how it works. Analogy: When you drive a car, you don’t have to know how the gasoline and air are mixed and ignited. Instead you only have to know how to use the controls. Draw map PVG's College of Engineering, Nashik 12
Polymorphism the same word or phrase can mean different things in different contexts Analogy: In English, bank can mean side of a river or a place to put money move - PVG's College of Engineering, Nashik 13
Function Overloading • The operation of one function depends on the argument passed to it. • Example: Fly(), Fly(low), Fly(150) PVG's College of Engineering, Nashik 14
Inheritance Ø Inheritance—a way of organizing classes Ø Term comes from inheritance of traits like eye color, hair color, and so on. Ø Classes with properties in common can be grouped so that their common properties are only defined once. Ø Superclass – inherit its attributes & methods to the subclass(es). Ø Subclass – can inherit all its superclass attributes & methods besides having its own unique attributes & methods. PVG's College of Engineering, Nashik 15
An Inheritance Hierarchy Vehicle Superclass Subclasses Automobile Sedan Motorcycle Sports Car Luxury Bus School Bus What properties does each vehicle inherit from the types of vehicles above it in the diagram? PVG's College of Engineering, Nashik 16
Benefits of OOP ØThrough inheritance, we can eliminate redundant code extend the use of existing Classes. ØWe can build programs from the standard working modules that communicate with one another, rather than having to start writing the code from scratch. This leads to saving of development time and higher productivity. ØThe principle of data hiding helps the programmer to build secure program that can not be invaded by code in other parts of a programs. ØIt is possible to have multiple instances of an object to co-exist without any interference. ØIt is possible to map object in the problem domain to those in the program. PVG's College of Engineering, Nashik 17
Benefits of OOP It is easy to partition the work in a project based on objects. The data-centered design approach enables us to capture more detail of a model can implemental form. Object-oriented system can be easily upgraded from small to large system. Message passing techniques for communication between objects makes to interface descriptions with external systems much simpler. Software complexity can be easily managed PVG's College of Engineering, Nashik 18
Application of OOP • Real Time systems • Simulation and modeling • Object oriented databases • Hypertext, Hypermedia and experttext • AI and expert systems • Neural networks and parallel programming • Decision support and office automation systems • CIM/CAD systems PVG's College of Engineering, Nashik 19
- Slides: 19