View
219
Download
0
Embed Size (px)
Citation preview
8/10/2019 Presentacin 2 - Objetos I
1/41
Objects & Classes I
Object Oriented Programming
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
2/41
Agenda
How our brainmanage knowledge
Object OrientedApproach
Objects & Classes
Objects in Java
Instantiating Objects:A Closer Look
8/10/2019 Presentacin 2 - Objetos I
3/41
Abstraction
Abstraction hierarchyAbstraction and software development
ow our ra n manage now e ge
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
4/41
How our brain manage knowledge
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
5/41
How our brain manage knowledge
Objects & Classes
What do you remember?
8/10/2019 Presentacin 2 - Objetos I
6/41
How our brain manage knowledge
Our brains naturally
simplify the details ofall that we observe.
Objects & Classes
Details aremanageable through
a process known asabstraction.
8/10/2019 Presentacin 2 - Objetos I
7/41
Process that involves recognizing and focusingon the im ortant characteristics of a situation
Abstraction
or object, and filtering out or ignoring all of theunessential details.
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
8/41
8/10/2019 Presentacin 2 - Objetos I
9/41
Simple abstraction hierarchy
Sport car
Vehicle
Truck Car Bicycle
Focusing on a small subset of
the hierarchy is lessoverwhelming.
Objects & Classes
rules
Small
Two seat
Luxury
High speed
Sport
Lotus ElanM100
AlpineA110
PorscheBoxster
8/10/2019 Presentacin 2 - Objetos I
10/41
Simple abstraction hierarchy
Objects & Classes
Correct classification
8/10/2019 Presentacin 2 - Objetos I
11/41
Abstraction and software development
Developing anabstraction of the
Objects & Classes
problem is anecessary first stepof all softwaredevelopment.
8/10/2019 Presentacin 2 - Objetos I
12/41
Objects & Classes
State / Data / AttributesBehavior / Operations / Methods
ec r en e pproac
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
13/41
What is OOP?
The logical approach used insoftware engineering that
describes how a programminglanguage is implemented.
It is a programming paradigm where developersthink of a program as a collection of interactingobjects
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
14/41
What is a object?
Merriam-Websters Collegiate Dictionary
Objects & Classes
Physical objects
Person
Student
Professor
Conceptual objects
Class
Grade
Age
8/10/2019 Presentacin 2 - Objetos I
15/41
What is a software object?
State(data)
Abstraction of
Objects & Classes
Behavior(functions)
-(physical orconceptual)
object
8/10/2019 Presentacin 2 - Objetos I
16/41
State is a group ofobjects attribute
values
State / Data / Attributes
Attributes aredata elements
used to describe
an object
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
17/41
State / Data / Attributes
Student attributes Student state
Objects & Classes
Birth date
ID
Program
Birth date: 22/JUL/1970
ID: 649851
Program: Computer Science
8/10/2019 Presentacin 2 - Objetos I
18/41
Behavior / Operations / Methods
Operations are
Objects & Classes
the things thatan object does
to modify itsattribute values
things that anobject does to
access itsattribute
8/10/2019 Presentacin 2 - Objetos I
19/41
Is a list of common attributes and behaviors for
a set of similar objects.
What is a class?
Objects & Classes
Class
example
Objectsexamples
8/10/2019 Presentacin 2 - Objetos I
20/41
8/10/2019 Presentacin 2 - Objetos I
21/41
Creating the Student Class
Attribute Typeid integer
name String
surName String
Objects & Classes
birthDate Datepapa double
advisor ???
courses ???
A class definition is like a class construction template
8/10/2019 Presentacin 2 - Objetos I
22/41
Is the process by which an object is created in
memory based upon a class definition.
Instantiation
Attribute Type Value
Objects & Classes
n eger o e e erm ne
name String To be determined
surName String To be determined
birthDate Date To be determined
papa double To be determined
advisor ??? To be determined
courses ??? To be determined
Class definition
8/10/2019 Presentacin 2 - Objetos I
23/41
Instantiation
Instantiation
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
24/41
8/10/2019 Presentacin 2 - Objetos I
25/41
Encapsulation
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
26/41
Encapsulation - Accessor and mutators
Objects & Classes
Accessor
Mutator
8/10/2019 Presentacin 2 - Objetos I
27/41
Using Accessor and mutators
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
28/41
Encapsulation benefits
hiding all the internal detail
Objects & Classes
protective barrier
8/10/2019 Presentacin 2 - Objetos I
29/41
Working with reference variables
Garbage collector
Instantiating Objects: A Closer Look
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
30/41
Instantiation - Working with reference variables
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
31/41
Instantiation - Working with reference variables
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
32/41
Instantiation - Working with reference variables
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
33/41
Instantiation - Working with reference variables
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
34/41
Instantiation - Working with reference variables
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
35/41
Instantiation - Working with reference variables
Objects & Classes
I i i W ki i h f i bl
8/10/2019 Presentacin 2 - Objetos I
36/41
Instantiation - Working with reference variables
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
37/41
Where domyballoons
Objects & Classes
w go
G b ll ti
8/10/2019 Presentacin 2 - Objetos I
38/41
Garbage collection
Objects & Classes
8/10/2019 Presentacin 2 - Objetos I
39/41
Class activity
8/10/2019 Presentacin 2 - Objetos I
40/41
1. Abstract the model to submit the grades of astudent in the SIA (Classes, behaviors, attributes,
Class activity
2. Create a Java project in NetBeans or Eclipse3. Create the Java classes of the proposed model
4. Encapsulate the classes
Objects & Classes
References
8/10/2019 Presentacin 2 - Objetos I
41/41
[Barker] J. Barker, Beginning Java Objects: From Concepts To
Code, Second Edition, Apress, 2005.
[Deitel] H.M. Deitel and P.J. Deitel, Java How to Program, PrenticeHall 2007 - 7th ed.
References
[Sierra] K. Sierra and B. Bates, Head First Java, 2nd Edition,O'Reilly Media, 2005.
Objects & Classes