ch6 Object Oriented Concepts
ch6 Object Oriented Concepts
fer 6
=
'<ii!!!! - - =;:,' - = -
Obiect-Oriented Concepts
~
Object-oriented Programming
t Playing significant role in analysis, design and
co
Way of Programming
t Programming can be divided Into two categories :
~ ) Structure/ Procedural Programming
• The focus is on writing functions or procedures.
• Ex: Library- Stud. registration, book issue, return etc.
(2) Object-oriented Programming
• The focus Is on objects, which contain both data and
functionality together.
• Ex : Library - Student, Book, Library
• Object is fundamental building block in Object-oriented.
IT]
Object-oriented - Properties
t A computer language is object-oriented if they supports
below four specific object properties :
(1) Abstraction
(2) Encapsulation
(3) Polymorphism
(4) Inheritance
t Object-oriented programming uses object as its
fundamental building block.
Class
t Class can be considered as a blueprint for various objects.
t It is a template for multiple objects with similar features.
t Class is general concept used to embody all the common
features of a particular set of objects.
t It describes a group of...o.bjects with similar attributes and
common behaviour.
t Objects in the same class share a common semantic
purpose.
Example: Class Person
Object Name, Citv, Gender, Birthdate
O:J
Class Diagram
tThe purpose of the class diagram is to model the static
view of an application.
t Class diagram are the only diagrams which can be directly
mapped with object oriented language.
t Unified Modeling Language (UML) can be used to create
models of object-oriented software.
t UML is a visual modeling language.
t It defined and maintained by Object Management Group (OMG).
[TI
Class Diagram - Representation
t Class diagram, a class is represented with an icon using a
rectangle split into three sections :
(2)
(3) Public +
(4) Package -
Enapsulation
tThe mechanism of providing protection t o data and
methods of a program is called Encapsulation. -
t Encapsulation provides data hiding capability.
t Encapsulation keeps the data safe from unintended
actions and inadvertent access by outside objects.
t Computer program, two core elements are data & functions.
t Structured/Procedural programming views these two core
elements as two separate entities.
tObject-oriented programming views them as single entity.
[!!]
Data Abstraction
t Data abstraction is a process of representing the es~
--
details. -
features of the objects without including implementation
---
things in different contexts is called overloadi'!&,._
-
t It represents 'has-a' or 'a-part-of relationship between classes.
Example :
Du
Aggregation v/s Composition
t Aggregation represents non-exclusive relationship.
t Motherboard is part of the computer; it can exist as a
separate item independent of the computer.
t If address object may be shared by two or more persons,
so address is not exclusive to any one person.
t Composition represents exclusive relationship.
tExample :
Name is associated exclusively with single person.
Inheritance
t Inheritance referred to a elationship.
t It is appropriate when one class is 'a-kind-of other class.
tExample :
• Teacher is a kind of person.
• All attribute and methods of class 'Person' are
applicable to class 'Teacher' also.
t New class is called as sub class, child class or derived class.
t Existing class is called as super class, parent class or base
class.