11/09/17
1
1
2017/2018
POO - Programação Orientada por Objetos OOP - Object-oriented programming
José Valente de [email protected]
www.ualg.pt | w3.ualg.pt/~jvo/poo
11/09/17
2
A welcome in Java programming language
class X {public static void main(String [] a) {
System.out.print(”Welcome\n"); }
} #include <stdio.h> int main(void) {
printf(”Welcome\n"); return 0;
}
[email protected] José Valente de Oliveira 4-4
Classes and objectsn A class can be seen as a description of a set
of objects sharing the same data structure(not the same data) and the same behaviour(functions)
11/09/17
3
What’s an object?
n An object represents a concrete entity of the problem domain, that handles a specific task
n Examples include:q Tangible things as cars, bank accountsq Roles as employee, boss, ...q Interactions as contract, sale, ...
n An object is like a black box: Internal details are hidden.
[email protected] José Valente de Oliveira 4-6
What’s an object?n An object can be seen as an abstraction
which represents an entity with interest forthe problem to solve.
n An object has:q Stateq Behaviourq Identity
11/09/17
4
[email protected] José Valente de Oliveira 4-7
What’s an object?n An object can be seen as an abstraction
which represents an entity with interest forthe problem to solve.
n An object has:q Stateq Behaviourq Identity
Point A is an object with:
-State: Coordinates (XA=1, YA=1)
- Behaviour: computes the distance between itself and another point
- Identify: Object point A is different from any other object
[email protected] José Valente de Oliveira 4-8
Examples of classes and their objects
Class Objects Data Typical functions
Point (0, 0)(4.5; 7.2)
x=0; y =0x=4,5; y=7.2
dist
BankAccount account1 Balance=0Number=12
Transferwithdraw
Fraction ½ Numerator = 1Denominator =2
sum
11/09/17
5
OOP Basics
n Identifying objects and assigning responsibilities to these objects.
n Objects communicate with other objects by sending messages.
n Build complex objects based on simple ones
n Three basic ideas:
Procedural vs. Object-Orientedn Procedural
Focus on procedures: credit, debit, compute interest
n Object Oriented
Focus on entities with a well-defined role in the problem domain:Customer, Account
11/09/17
6
Procedural vs. Object-Oriented
Why should we care about OOP?
n Modularity - large software projects can besplitted into independent, self-containedmodules.
n Reusability - Programs can be assembledfrom pre-written software components.
n Extensibility - New software components canbe written or developed from existing ones.
11/09/17
7
Course main topics
n Elementary concepts of OOP
n Introduction to Object Oriented Modelling and UML (Unified Modelling Language)
n Principles, concepts and techniques of OOP
n Object Oriented Programming using Java
n Elementary data structures
n Fundamental Design Patterns
Learning outcomesn Understand Object Oriented programming
principles and techniques
n Application modelling using UML
n Be familiar with fundamental Design Patterns
n Use Java as a programming language
11/09/17
8
From: http://www.tiobe.com/
TIOBE Programming Community Index for September 2017
From: http://www.tiobe.com
Long term trends of Tiobe indices as of September 2017
11/09/17
9
From: http://www.payscale.com
Median salary by years of experience
Bibliographyn [Main textbook]
Bruce Eckel, Thinking in Java, 4th edition, Prentice Hall, New Jersey, cf. http://mindview.net/Books/TIJ4
n [Supplementary readings on UML]UML Quick Ref. www.uml.org
11/09/17
10
Bibliography
n [Supplementary readings on Design patterns]Erich Gamma, Richard Helm, Ralph
Johnson, John Vlissides, Design Pattern – Elements of Reusable Object-Oriented Software, Addison-Wesley, 1995
[Supplementary readings on Data Structures]Robert Sedgewick. “Algorithms in Java,
3rd edition – parts 1-4: Fundamentals, data structures, sorting, searching”, Addison-Wesley, 2003
Assessmentn Final grade (any season) =
60% final written exam + 40% Lab assignments
n Approval if final grade >= 9.5 (round offs are only applicable to the final grade)
n Admission to final exams: all registered students with i) lab assessment grade >= 7,5 (any season)ii) lab presences >= 2/3
n Final written exam is partially open book, i.e., 25 A4 student prepared pages can be used as consulting material
11/09/17
11
Lab assessment
n Lab assessent equals the weighted sum of lab assignments
n Lab assignments are made in working groups of 2 or 3 elements.
n However, the assegment is individual, and depends of the student preformance during the assignment defence.
n Groups registration (for both assignments and classes) is mandatory and should be made at:
www.deei.fct.ualg.pt/POO/Entregas
Labsn Some assignments (i.e.,tutorials) consist only in submitting source code to
Mooshak
n Other assignments (i.e., problems) requires both the submission of source code and a report
n Submissions beyond the deadline will reduce global lab assessment (0.25v per day)
n Criteria for assessment of the assignments: - Correction features that exceed specifications will not be
considered for assessment- Efficiency use of resources: CPU, RAM, etc. - Code reusability - Readability including comments to document the code
11/09/17
12
To take away todayn What’s OOP?n Goals for this coursen Main covered topicsn Recommend bibliographyn Assessmentn OOP web resourses