oops concept and implementation
Post on 15-Feb-2017
23 Views
Preview:
TRANSCRIPT
www.sblcorp.com
OOPs Concept and Implementation
Presented by, Sandeep Kumar
SBL Controlled
www.sblcorp.com
Agenda
SBL Controlled
• Understad OOP Concepts
• OOP Implementation
• Benefits of OOP
2 of 23
www.sblcorp.com
Problem
SBL Controlled3 of 23
Create a feedback form application
www.sblcorp.com
Problem SolvingAnalyse the problem
• Feedback Form
• Objective Question
• Multi Select Question
• Subjective Question
SBL Controlled4 of 23
www.sblcorp.com
What is Object Oriented Programming
SBL Controlled
• Programming concepts purely based on Objects.
• Objects are like real world objects
• Object has its own properties(data) and behaviors(functions) like any real world objects
• Class - Description of object
• OOPs concepts are invented to make programming and problem solving easy by relating problem to real world scenarios.
5 of 23
www.sblcorp.com
What are the OOPs concepts
SBL Controlled
• Inheritance
• Abstraction
• Encapsulation
• Polymorphism
6 of 23
www.sblcorp.com
Problem Solving
SBL Controlled
ObjectiveQuestion
questionText
optionsList
MultiSelectQuestion
questionText
optionsList
SubjectiveQuestion
questionText
7 of 23
www.sblcorp.com
Inheritace
SBL Controlled
ObjectiveQuestion
optionsList
MultiSelectQuestion
optionsList
SubjectiveQuestion
Question
questionText
8 of 23
www.sblcorp.com
Inheritance (Make reusable)
SBL Controlled
• Creating a new class from existing class is called inheritance.
• Existing class is parent class
• New class is child class
• And the new class has the inheritable property of its parent class and its own properties
9 of 23
www.sblcorp.com SBL Controlled10 of 23
www.sblcorp.com
Problem Solving
SBL Controlled
ObjectiveQuestion
questionText
optionsList
MultiSelectQuestion
questionText
optionsList
SubjectiveQuestion
questionText
setAnswer() setAnswer() setAnswer()
11 of 23
www.sblcorp.com
Abstraction
SBL Controlled12 of 23
www.sblcorp.com
Abstraction (Make it as a type)
SBL Controlled
• Class is the description of Object
• Abstract class is the description of a class
• Question is abstraction of ObjectiveQuestion, MultiselectQuestion, SubjectiveQuestion
• abstract - existing in thought or as an idea but not having a physical or concrete existence
• Abstract class is used to inherit and create new child derived, like in real world object car is not exist, but car companies use basic car concept to create their own cars by adding their own idea.
• Similarly we cannot create Question question = new Question();
13 of 23
www.sblcorp.com
Encapsulation
SBL Controlled14 of 23
www.sblcorp.com
Encapsulation (Capsulate things)
SBL Controlled
• Modulizing things
• Capsulate data and function into a single entity
• Ability to hide certain parts of themselves from programmers
• Data hiding is done with access modifier private protected and public keywords.
• private - only accecible to class
• protected - accesible to class, child class, same package
• public - No acces restrictions
• From whom we hide data?
15 of 23
www.sblcorp.com
Encapsulation - Data hiding
SBL Controlled
System Library
BatteryManager
chargePercentage
protected setCharge()public getCharge()
• setCharge() is a protected method, so only system can acces that method
• System reads charge value from battery hardware and update to chargePercentage using setCharge()
• Library, SDK ( Software Development Kit)
16 of 23
www.sblcorp.com
Polymorphism ( Many Forms)
SBL Controlled
• Polymorphism - One thing has several different forms
• Many forms of representation of an object
• We can represent ObjectiveQuestion in many forms like
• ObjectiveQuestion is a ObjectiveQuestion
• ObjectiveQuestion objectiveQuestion = new ObjectiveQuestion();
• ObjectiveQuestion is a Question
• Question question = new ObjectiveQuestion();
17 of 23
www.sblcorp.com
Polymorphism
SBL Controlled18 of 23
www.sblcorp.com
Polymorphism
SBL Controlled
Traverse through all questions
19 of 23
www.sblcorp.com
If no Polymorphism
SBL Controlled20 of 23
www.sblcorp.com
If no Polymorphism
SBL Controlled
Traverse through all questions
21 of 23
www.sblcorp.com
Benefits of oops
SBL Controlled
• Code Reuse and Recycling: Objects created for Object Oriented Programs can easily be reused in other programs.
• Encapsulation: Once an Object is created, knowledge of its implementation is not necessary for its use. In older programs, coders needed understand the details of a piece of code before using it (in this or another program).
• Software Maintenance : An Object Oriented Program is much easier to modify and maintain than a non-Object Oriented Program. So although a lot of work is spent before the program is written, less work is needed to maintain it over time
• Improve code quality: Each class is written in each file. Which makes for better designs with less flaws. That improves code readability
22 of 23
www.sblcorp.com
Thank You
SBL Controlled23 of 23
top related