Download presentation
Published byCoral Jacobs Modified over 9 years ago
1
Course Description: Title : Object Oriented Systems
Paper Code : CA - 205 Course : MCA Faculty : Ms. Charu Sharma Vikrant Gupta
2
Course Objectives & Prerequisites:
The course aims is to introduce the students to Object Oriented Programming Concepts with special emphasis on Object Oriented Programming in C++. The course begins with a gentle introduction to OOAD and OOP concepts. Students will then be presented with detailed discussion of Object Oriented Programming features in C++. At the end the use of few applications of OOAD and OOP concepts in areas like Software Engineering and Operating Systems. In order to take the course the student should be familiar with Digital Computer System and must have completed a basic course in Computer Programming, preferably in C.
3
Object Oriented Programming
4
Programming evolution
Machine code ● programs in binary code, executed directly by the processor Assembly languages ● still low level programming, replaced machine code functions with mnemonics and memory addresses with symbolic labels Procedural programming ● decompose programs into procedures/functions Modular Programming ● decompose programs into modules Object Oriented Programming ● decompose program into a set of objects ● objects interact with each other to form a system
5
What is OOP? OOP is a design philosophy. It stands for Object Oriented Programming. Object-Oriented Programming (OOP) uses a different set of programming languages than old procedural programming languages (C, Pascal, etc.). Everything in OOP is grouped as self sustainable "objects“.
6
What is OOP?(Cont’d) In order to clearly understand the object orientation, let’s take your “hand” as an example. The “hand” is a class. Your body has two objects of type hand, named left hand and right hand. Their main functions are controlled/ managed by a set of electrical signals sent through your shoulders (through an interface). So the shoulder is an interface which your body uses to interact with your hands. The hand is a well architected class. The hand is being re- used to create the left hand and the right hand by slightly changing the properties of it.
7
Problem Description “ customers are allowed to have different types of bank accounts, deposit money, withdraw money and transfer money between accounts”
8
Procedural Approach bool MakeDeposit(int accountNum,float amount); float Withdraw(int accountNum,float amount); struct Account { char *name; int accountNum; float balance; char accountType; };
9
Procedural Approach cont’d
Focus is on procedures All data is shared: no protection More difficult to modify Hard to manage complexity
10
Procedural vs. Object-Oriented
Withdraw, deposit, transfer Object Oriented Customer, money, account
11
Mapping the world to software
Objects in the problem domain are mapped to objects in software 011101 10011 11101 11010 010101 10101
12
Object Oriented Account Data and operations are grouped together
Interface: Set of available operations Deposit Withdrawl Transfer
13
Object Oriented Paradigm
Provide flexible and powerful abstraction Allow programmers to think in terms of the structure of the problem rather than in terms of the structure of the computer. ● Decompose the problem into a set of objects ● Objects interact with each other to solve the problem ● create new type of objects to model elements from the problem space An object is an entity that: ● has a local state ● able perform some operation (behavior)
14
Object Oriented Paradigm(Cont’d)
It may be viewed as a combination of: ● data (attributes) ● procedural elements (methods) Object Oriented Programming is a method of implementation where: objects are fundamental building blocks ● each object is an instance of some type (class) ● classes are related to each others by inheritance
15
Fundamental concepts and properties
● object ● class ● method (message) Properties: ● encapsulation ● inheritance ● polymorphism
16
Objects and Classes object class
Classes reflect concepts, objects reflect instances that embody those concepts. object class girl Jodie Daria Jane Brittany
17
Objects and Classes (cont’d)
A class captures the common properties of the objects instantiated from it A class characterizes the common behavior of all the objects that are its instances
18
Objects and Classes (cont’d)
Operations MakeDesposit Transfer WithDraw GetBalance Class BankAccount Balance InterestYTD Owner Account_number Balance 500 InterestYTD Owner Account_number Balance 10,000 InterestYTD Owner Account_number
19
Objects as instances of Classes
The world conceptually consists of objects Many objects can be said to be of the same type or class My bank account, your bank account, Bill Gates’ bank account … We call the object type a class
20
Instantiation An Object is instantiated from a Class
BankAccount myAccount; myAccount = new BankAccount;
21
Objects and Classes Class Object Visible in source code
The code is not duplicated Object Own copy of data Active in running program Occupies memory Has the set of operations given in the class
22
Classification Mammal Rodent Primate Cats Reptile Animal Squirel
Rabbit Mouse
23
Classification Checking Account Value First Select Access
First Interest Savings Account Account
24
Encapsulation Abstraction in OOP is closely related to a concept called encapsulation. Data and the ways to get at that data are wrapped in a single package, a class. The only way to access such data is through that package. This idea translates to information hiding.
25
Encapsulation (Cont’d)
Encapsulation is the method of combining the data and functions inside a class. This hides the data from being accessed from outside a class directly, only through the functions inside the class is able to access the information. This is also known as "Data Abstraction", as it gives a clear separation between properties of data type and the associated implementation details. There are two types, they are "function abstraction" and "data abstraction". Functions that can be used without knowing how its implemented is function abstraction. Data abstraction is using data without knowing how the data is stored.
26
Data Encapsulation class Account { public: float withdraw();
void deposit(float amount); private: float balance; );
27
Advantages of Encapsulation
Protection Consistency Allows change
28
Inheritance A class which is a subtype of a more general class is said to be inherited from it. The sub-class inherits the base class’ data members and member functions
29
Inheritance (Cont’d) A sub-class has all data members of its base-class plus its own A sub-class has all member functions of its base class (with changes) plus its own Inheritance is meant to implement sub-typing (don’t abuse it)
30
Inheritance Examples
31
University community members
Employee CommunityMember Student Faculty Staff Administrator Teacher
32
Abstraction Management of complexity Hierarchical classification:
is-a relationship: inheritance has-a relationship: containment
33
Abstraction Cont’d One of the chief advantages of object-oriented programming is the idea that programmers can essentially focus on the “big picture” and ignore specific details regarding the inner-workings of an object. This concept is called abstraction.
34
Polymorphism One interface Multiple implementations Inheritance
Method overloading
35
Polymorphism (Cont’d)
Polymorphism describes how programmers write methods to do some general purpose function. Different objects might perform polymorphic methods differently.
36
What is a good class ? A class abstracts objects
A class should be non-trivial in the context of the program (has data structures and operations different from other classes)
37
Motivation Procedural programming: Variables objects Types classes
Low-level, closer to hardware More intuitive, less abstract More ‘action’ oriented Focus on ‘action’, ‘procedure’, ‘method’ Procedure-oriented Object-oriented programming: High-level More abstract Focus on ‘what to do’ not on ‘how to do’ In the implementation of OOP, we still need sound ‘procedure programming’ skills!
38
Procedural programming: Object oriented programming:
A sequence of ‘procedures’ A sequence of ‘objects’! int main() { int x,y,z; int a,b,c; a=f1(x); b=f2(y); c=f3(z); … } int f1() int f2() int f3() int main() { A a; B b; C c; a.f1(); b.f2(); c.f3(); … } Class A Int x; Int f1(); Class B Int y; Int f2() Class C Int z; Int f3();
39
Object-oriented modeling and design
40
Introduction It is a new way of thinking about problems using models based on real world concepts. The basic construct is object which combines both data structure and behavior in a single entity. Rambaugh presents an object oriented software development methodology, the Object Modeling Technique (OMT) which extends from analysis through design to implementation.
41
What is object-oriented?
Software is organized as a collection of discrete objects that incorporate both data structure and behavior. In general it includes- identity, classification, polymorphism and inheritance. Object Oriented Programming Language = Object Based Programming Language(e.g. '83 Ada a Modula- 2,C++and Java,etc.) + Inheritance + Dynamic Binding
42
Identity Identity means that data is organized into discrete, distinguishable entities called objects. Objects can be concrete or conceptual. In real world an object simply exist but within a programming language each object has a unique handle by which it can be uniquely referenced. The handle can be implemented by address, array index or unique value of an attribute.
43
Classification It means that objects with same data structure (attribute) and behavior (operations) are grouped into a class. A class is an abstraction that describes important properties and ignores the rest.
44
Polymorphism It means that the same operation (i.e. action or transformation that the object performs) may behave differently on different classes. Specific implementation of an operation by a certain class is called a method.
45
Inheritance It is the sharing of attributes and operations among classes based on a hierarchical relationship. Subclasses can be formed from broadly defined class. Each subclass incorporates or inherits all the properties of its super class and adds its own unique properties.
46
Object-Oriented Development?
The theme is the identification and organization of application concepts rather than final representation in a prog. Language. OOD approach encourages software developers to work and think in terms of the application domain through most of the software engineering life cycle. It is a conceptual process independent of a programming language until the final stage.
47
Object-Oriented Methodology
Stages. Analysis System design Object design Implementation
48
3 Models Object Model Dynamic model Functional model
49
Object Model Describes basic structure of objects and their relationship. Contains object diagram. Object diagram is a graph whose nodes are object classes (Classes) and whose arcs are relationships among classes.
50
Dynamic model Describes the aspects of a system that change over time.
It specifies and implement control aspects of a system. Contains state diagram. State diagram is a graph whose nodes are states and whose arcs are data-flows.
51
Functional Model Describes data value transformation within a system.
Contains data flow diagram. Data Flow Diagram is a graph whose nodes are processes and whose arcs are data flows.
52
Object-Oriented Concepts
Abstraction Encapsulation Combining data and behavior Sharing Object structure, not Procedure Structure Synergy
53
On completion of the class, a student should be able:
To prepare object-oriented design for small/medium scale problems To demonstrate the differences between traditional imperative design and object-oriented design To explain class structures as fundamental, modular building blocks To understand the role of inheritance, polymorphism, dynamic binding and generic structures in building reusable code To write small/medium scale c++ programs with simple graphical user interface To use classes written by other programmers when constructing their systems
54
Summary What is Object Oriented Programming? Object-oriented programming is a method of implementation in which programs are organized as cooperative collections of objects, each of which represents an instance of some class, and whose classes are all members of one or more hierarchy of classes united via inheritance relationships
55
Expected Result 100%
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.