SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
Abstract classes and interfaces
Sérgio Souza Costa
Universidade Federaldo Maranhão
28 de junho de 2016
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 1 / 17
Based in Dan Pilone. “UML 2.0 in a Nutshell.”
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 2 / 17
Summary
Association
Aggregation
Composition
Assignment
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 3 / 17
Dependency
The weakest relationship between classes, means that one class uses, or has knowledge of,
another class. It is typically a transient relationship, meaning a dependent class briefly
interacts with the target class but typically doesn’t retain a relationship with it for any real
length of time.
Are typically read as "...uses a...”.For example, if you have a class named Window that
sends out a class named WindowClosingEvent when it is about to be closed, you would say
"Window uses a WindowClosingEvent.”
You show a dependency between classes using a dashed line with an arrow pointing from
the dependent class to the class that is used.
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 4 / 17
Association
Associations are stronger than dependencies and typically indicate that one class retains a
relationship to another class over an extended period of time.
Are typically read as "...has a...". For example, if you have a class named Window that
has a reference to the current mouse cursor, you would say "Window has a Cursor". .
You show an association using a solid line between the classes participating in the
relationship.
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 5 / 17
Navigability
“Associations have explicit notation to express navigability. If you can navigate from one
class to another, you show an arrow in the direction of the class you can navigate to. ”
“Because you can’t navigate from an instance of Cursor to an instance of Window, we
explicitly show the navigability arrow and an X where appropriate.”
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 6 / 17
Multiplicity
You can express how many instances of a particular class are involved in a relationship. I
You don’t specify a value, a multiplicity of 1 is assumed. To show a different value, simply
place the multiplicity specification near the owned class.
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 7 / 17
Example
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 8 / 17
Example - Item
public class Item {
...
public Item(int c, int q, float v, Produto p){
codigo =c;
qde = q;
valor = v;
prod = p;
}
public cal_valor(){
valor = qde * prog.get_preco();
}
}
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 9 / 17
Example - Produto
public class Produto {
private int codigo;
private String nome;
private float preco;
public Produto(int c, String n, float p){
codigo=c;
nome=n;
preco=p;
}
public double get_preco(){
return preco;
}
}
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 10 / 17
Example 2
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 11 / 17
Example 2 - Cliente
import java.util.Vector;
public class Cliente{
private String nome;
private String endereco;
private Vector ped;
public Cliente(String n,String e){
nome=n;
endereco=e;
ped=newVector();
}
public int get_size(){
return ped.size();
}
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 12 / 17
Example 2 - Cliente
public void add_pedido(Pedido p){ ped.addElement(p); }
public Pedido get_pedido(int i){ return (Pedido)ped.elementAt(i); }
public void exc_pedido(int id){
Pedido aux;
int tam=ped.size();
for(inti=0;i<tam;i++){
aux=(Pedido)ped.elementAt(i);
if(aux.get_id()==id){
ped.removeElementAt(i);
}
}
}}
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 13 / 17
Agregation
Is a stronger version of association. Unlike association, aggregation typically implies
ownership and may imply a relationship between lifelines.
Aggregations are usually read as "...owns a...". For example, if you had a classed named
Window that stored its position and size in a Rectangle class, you would say the "Window
owns a Rectangle.”
In the association example, Window doesn’t own the Cursor; Cursor was shared between
all applications in the system.”
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 14 / 17
Composition
Composition represents a very strong relationship between classes, to the point of
containment.
Composition is used to capture a whole-part relationship.
The lifetime of instances involved in composition relationships is almost always linked; if
the larger, owning instance is destroyed, it almost always destroys the part piece.
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 15 / 17
Composition and the design patterns
The Gang of Four suggests a few strategies for creating good object- oriented designs. In
particular, they suggest the following:
Design to interfaces.
Favor composition over inheritance
Find what varies and encapsulate it.
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 16 / 17
Assignment
Implementem as classes e suas relações como no diagrama abaixo.
Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 17 / 17

Mais conteúdo relacionado

Mais procurados

‫‫Chapter4 Polymorphism
‫‫Chapter4 Polymorphism‫‫Chapter4 Polymorphism
‫‫Chapter4 PolymorphismMahmoud Alfarra
 
Seminar on java
Seminar on javaSeminar on java
Seminar on javashathika
 
Inheritance and Polymorphism Java
Inheritance and Polymorphism JavaInheritance and Polymorphism Java
Inheritance and Polymorphism JavaM. Raihan
 
Chapter 8.2
Chapter 8.2Chapter 8.2
Chapter 8.2sotlsoc
 
06 abstract-classes
06 abstract-classes06 abstract-classes
06 abstract-classesAnup Burange
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methodsShubham Dwivedi
 
‫Object Oriented Programming_Lecture 3
‫Object Oriented Programming_Lecture 3‫Object Oriented Programming_Lecture 3
‫Object Oriented Programming_Lecture 3Mahmoud Alfarra
 
Abstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaAbstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaMOHIT AGARWAL
 
JAVA Notes - All major concepts covered with examples
JAVA Notes - All major concepts covered with examplesJAVA Notes - All major concepts covered with examples
JAVA Notes - All major concepts covered with examplesSunil Kumar Gunasekaran
 
البرمجة الهدفية بلغة جافا - الوراثة
البرمجة الهدفية بلغة جافا - الوراثةالبرمجة الهدفية بلغة جافا - الوراثة
البرمجة الهدفية بلغة جافا - الوراثةMahmoud Alfarra
 
Java assignment help
Java assignment helpJava assignment help
Java assignment helpJacob William
 
البرمجة الهدفية بلغة جافا - تعدد الأشكال
البرمجة الهدفية بلغة جافا - تعدد الأشكالالبرمجة الهدفية بلغة جافا - تعدد الأشكال
البرمجة الهدفية بلغة جافا - تعدد الأشكالMahmoud Alfarra
 
Chap3 inheritance
Chap3 inheritanceChap3 inheritance
Chap3 inheritanceraksharao
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentationtigerwarn
 
البرمجة الهدفية بلغة جافا - مفاهيم أساسية
البرمجة الهدفية بلغة جافا - مفاهيم أساسية البرمجة الهدفية بلغة جافا - مفاهيم أساسية
البرمجة الهدفية بلغة جافا - مفاهيم أساسية Mahmoud Alfarra
 
Pi j3.2 polymorphism
Pi j3.2 polymorphismPi j3.2 polymorphism
Pi j3.2 polymorphismmcollison
 
Interfaces and abstract classes
Interfaces and abstract classesInterfaces and abstract classes
Interfaces and abstract classesAKANSH SINGHAL
 

Mais procurados (20)

‫‫Chapter4 Polymorphism
‫‫Chapter4 Polymorphism‫‫Chapter4 Polymorphism
‫‫Chapter4 Polymorphism
 
Seminar on java
Seminar on javaSeminar on java
Seminar on java
 
Inheritance and Polymorphism Java
Inheritance and Polymorphism JavaInheritance and Polymorphism Java
Inheritance and Polymorphism Java
 
Chapter 8.2
Chapter 8.2Chapter 8.2
Chapter 8.2
 
06 abstract-classes
06 abstract-classes06 abstract-classes
06 abstract-classes
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
‫Object Oriented Programming_Lecture 3
‫Object Oriented Programming_Lecture 3‫Object Oriented Programming_Lecture 3
‫Object Oriented Programming_Lecture 3
 
Abstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaAbstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core Java
 
JAVA Notes - All major concepts covered with examples
JAVA Notes - All major concepts covered with examplesJAVA Notes - All major concepts covered with examples
JAVA Notes - All major concepts covered with examples
 
البرمجة الهدفية بلغة جافا - الوراثة
البرمجة الهدفية بلغة جافا - الوراثةالبرمجة الهدفية بلغة جافا - الوراثة
البرمجة الهدفية بلغة جافا - الوراثة
 
Java assignment help
Java assignment helpJava assignment help
Java assignment help
 
البرمجة الهدفية بلغة جافا - تعدد الأشكال
البرمجة الهدفية بلغة جافا - تعدد الأشكالالبرمجة الهدفية بلغة جافا - تعدد الأشكال
البرمجة الهدفية بلغة جافا - تعدد الأشكال
 
Chap3 inheritance
Chap3 inheritanceChap3 inheritance
Chap3 inheritance
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
 
E3
E3E3
E3
 
البرمجة الهدفية بلغة جافا - مفاهيم أساسية
البرمجة الهدفية بلغة جافا - مفاهيم أساسية البرمجة الهدفية بلغة جافا - مفاهيم أساسية
البرمجة الهدفية بلغة جافا - مفاهيم أساسية
 
Abstract method
Abstract methodAbstract method
Abstract method
 
Pi j3.2 polymorphism
Pi j3.2 polymorphismPi j3.2 polymorphism
Pi j3.2 polymorphism
 
Abstract classes
Abstract classesAbstract classes
Abstract classes
 
Interfaces and abstract classes
Interfaces and abstract classesInterfaces and abstract classes
Interfaces and abstract classes
 

Destaque

DBCells - an open and global multi-scale linked cells
DBCells - an open and global multi-scale linked cellsDBCells - an open and global multi-scale linked cells
DBCells - an open and global multi-scale linked cellsSérgio Souza Costa
 
Paradigma orientado a objetos - Caso de Estudo C++
Paradigma orientado a objetos - Caso de Estudo C++Paradigma orientado a objetos - Caso de Estudo C++
Paradigma orientado a objetos - Caso de Estudo C++Sérgio Souza Costa
 
Conceitos básicos de orientação a objetos
Conceitos básicos de orientação a objetosConceitos básicos de orientação a objetos
Conceitos básicos de orientação a objetosSérgio Souza Costa
 
Informação Geográfica nos Dispositivos Móveis
Informação Geográfica nos Dispositivos MóveisInformação Geográfica nos Dispositivos Móveis
Informação Geográfica nos Dispositivos MóveisSérgio Souza Costa
 
Desafios para a modelagem de sistemas terrestres (2008)
Desafios para a modelagem de sistemas terrestres (2008)Desafios para a modelagem de sistemas terrestres (2008)
Desafios para a modelagem de sistemas terrestres (2008)Sérgio Souza Costa
 
From remote sensing to agent-based models
From remote sensing to agent-based modelsFrom remote sensing to agent-based models
From remote sensing to agent-based modelsSérgio Souza Costa
 
AppInventor - Conhecendo o ambiente e seus principais componentes
AppInventor - Conhecendo o ambiente e seus principais componentesAppInventor - Conhecendo o ambiente e seus principais componentes
AppInventor - Conhecendo o ambiente e seus principais componentesSérgio Souza Costa
 
Explorando o HTML5 para visualização de dados geográficos
Explorando o HTML5 para visualização de dados geográficosExplorando o HTML5 para visualização de dados geográficos
Explorando o HTML5 para visualização de dados geográficosSérgio Souza Costa
 
AppInventor - Blocos condicionais e explorando alguns recursos do smartphone
AppInventor - Blocos condicionais e explorando alguns recursos do smartphoneAppInventor - Blocos condicionais e explorando alguns recursos do smartphone
AppInventor - Blocos condicionais e explorando alguns recursos do smartphoneSérgio Souza Costa
 
Explorando Games para o Ensino do Pensamento Computacional
Explorando Games para o Ensino do Pensamento ComputacionalExplorando Games para o Ensino do Pensamento Computacional
Explorando Games para o Ensino do Pensamento ComputacionalSérgio Souza Costa
 
Árvores: Conceitos e binárias
Árvores:  Conceitos e bináriasÁrvores:  Conceitos e binárias
Árvores: Conceitos e bináriasSérgio Souza Costa
 
O fim dos SIGs: Como isso ira lhe_afetar ?
O fim dos SIGs: Como isso ira lhe_afetar ?O fim dos SIGs: Como isso ira lhe_afetar ?
O fim dos SIGs: Como isso ira lhe_afetar ?Sérgio Souza Costa
 

Destaque (20)

DBCells - an open and global multi-scale linked cells
DBCells - an open and global multi-scale linked cellsDBCells - an open and global multi-scale linked cells
DBCells - an open and global multi-scale linked cells
 
Paradigma orientado a objetos - Caso de Estudo C++
Paradigma orientado a objetos - Caso de Estudo C++Paradigma orientado a objetos - Caso de Estudo C++
Paradigma orientado a objetos - Caso de Estudo C++
 
Google apps script - Parte - 1
Google apps script - Parte - 1Google apps script - Parte - 1
Google apps script - Parte - 1
 
Google apps script - Parte 2
Google apps script - Parte 2Google apps script - Parte 2
Google apps script - Parte 2
 
Árvores balanceadas - AVL
Árvores balanceadas - AVLÁrvores balanceadas - AVL
Árvores balanceadas - AVL
 
Conceitos básicos de orientação a objetos
Conceitos básicos de orientação a objetosConceitos básicos de orientação a objetos
Conceitos básicos de orientação a objetos
 
Informação Geográfica nos Dispositivos Móveis
Informação Geográfica nos Dispositivos MóveisInformação Geográfica nos Dispositivos Móveis
Informação Geográfica nos Dispositivos Móveis
 
Desafios para a modelagem de sistemas terrestres (2008)
Desafios para a modelagem de sistemas terrestres (2008)Desafios para a modelagem de sistemas terrestres (2008)
Desafios para a modelagem de sistemas terrestres (2008)
 
From remote sensing to agent-based models
From remote sensing to agent-based modelsFrom remote sensing to agent-based models
From remote sensing to agent-based models
 
App inventor - aula 03
App inventor  - aula 03App inventor  - aula 03
App inventor - aula 03
 
Software
SoftwareSoftware
Software
 
AppInventor - Conhecendo o ambiente e seus principais componentes
AppInventor - Conhecendo o ambiente e seus principais componentesAppInventor - Conhecendo o ambiente e seus principais componentes
AppInventor - Conhecendo o ambiente e seus principais componentes
 
Explorando o HTML5 para visualização de dados geográficos
Explorando o HTML5 para visualização de dados geográficosExplorando o HTML5 para visualização de dados geográficos
Explorando o HTML5 para visualização de dados geográficos
 
AppInventor - Blocos condicionais e explorando alguns recursos do smartphone
AppInventor - Blocos condicionais e explorando alguns recursos do smartphoneAppInventor - Blocos condicionais e explorando alguns recursos do smartphone
AppInventor - Blocos condicionais e explorando alguns recursos do smartphone
 
Explorando Games para o Ensino do Pensamento Computacional
Explorando Games para o Ensino do Pensamento ComputacionalExplorando Games para o Ensino do Pensamento Computacional
Explorando Games para o Ensino do Pensamento Computacional
 
Contextualizando o moodle
Contextualizando o moodleContextualizando o moodle
Contextualizando o moodle
 
Comandos e expressões
Comandos e expressõesComandos e expressões
Comandos e expressões
 
Árvores: Conceitos e binárias
Árvores:  Conceitos e bináriasÁrvores:  Conceitos e binárias
Árvores: Conceitos e binárias
 
Funções e procedimentos
Funções e procedimentosFunções e procedimentos
Funções e procedimentos
 
O fim dos SIGs: Como isso ira lhe_afetar ?
O fim dos SIGs: Como isso ira lhe_afetar ?O fim dos SIGs: Como isso ira lhe_afetar ?
O fim dos SIGs: Como isso ira lhe_afetar ?
 

Mais de Sérgio Souza Costa

Expressões aritméticas, relacionais e lógicas
Expressões aritméticas, relacionais e lógicasExpressões aritméticas, relacionais e lógicas
Expressões aritméticas, relacionais e lógicasSérgio Souza Costa
 
De algoritmos à programas de computador
De algoritmos à programas de computadorDe algoritmos à programas de computador
De algoritmos à programas de computadorSérgio Souza Costa
 
Introdução ao pensamento computacional e aos algoritmos
Introdução ao pensamento computacional e aos algoritmosIntrodução ao pensamento computacional e aos algoritmos
Introdução ao pensamento computacional e aos algoritmosSérgio Souza Costa
 
Minicurso de introdução a banco de dados geográficos
Minicurso de introdução a banco de dados geográficosMinicurso de introdução a banco de dados geográficos
Minicurso de introdução a banco de dados geográficosSérgio Souza Costa
 
Banco de dados geográfico - Aula de Encerramento
Banco de dados geográfico - Aula de EncerramentoBanco de dados geográfico - Aula de Encerramento
Banco de dados geográfico - Aula de EncerramentoSérgio Souza Costa
 
Banco de dados geográficos – Arquiteturas, banco de dados e modelagem
Banco de dados geográficos – Arquiteturas, banco de dados e modelagemBanco de dados geográficos – Arquiteturas, banco de dados e modelagem
Banco de dados geográficos – Arquiteturas, banco de dados e modelagemSérgio Souza Costa
 
Banco de dados geográficos - Aula de abertura
Banco de dados geográficos - Aula de aberturaBanco de dados geográficos - Aula de abertura
Banco de dados geográficos - Aula de aberturaSérgio Souza Costa
 
Linguagem SQL e Extensões Espacias - Introdução
Linguagem SQL e Extensões Espacias - IntroduçãoLinguagem SQL e Extensões Espacias - Introdução
Linguagem SQL e Extensões Espacias - IntroduçãoSérgio Souza Costa
 
Gödel’s incompleteness theorems
Gödel’s incompleteness theoremsGödel’s incompleteness theorems
Gödel’s incompleteness theoremsSérgio Souza Costa
 
Aula 1 - introdução a fundamentos de computação
Aula 1 - introdução a fundamentos de computaçãoAula 1 - introdução a fundamentos de computação
Aula 1 - introdução a fundamentos de computaçãoSérgio Souza Costa
 

Mais de Sérgio Souza Costa (15)

Expressões aritméticas, relacionais e lógicas
Expressões aritméticas, relacionais e lógicasExpressões aritméticas, relacionais e lógicas
Expressões aritméticas, relacionais e lógicas
 
De algoritmos à programas de computador
De algoritmos à programas de computadorDe algoritmos à programas de computador
De algoritmos à programas de computador
 
Introdução ao pensamento computacional e aos algoritmos
Introdução ao pensamento computacional e aos algoritmosIntrodução ao pensamento computacional e aos algoritmos
Introdução ao pensamento computacional e aos algoritmos
 
Minicurso de introdução a banco de dados geográficos
Minicurso de introdução a banco de dados geográficosMinicurso de introdução a banco de dados geográficos
Minicurso de introdução a banco de dados geográficos
 
Modelagem de dados geográficos
Modelagem de dados geográficosModelagem de dados geográficos
Modelagem de dados geográficos
 
Banco de dados geográfico - Aula de Encerramento
Banco de dados geográfico - Aula de EncerramentoBanco de dados geográfico - Aula de Encerramento
Banco de dados geográfico - Aula de Encerramento
 
Banco de dados geográficos – Arquiteturas, banco de dados e modelagem
Banco de dados geográficos – Arquiteturas, banco de dados e modelagemBanco de dados geográficos – Arquiteturas, banco de dados e modelagem
Banco de dados geográficos – Arquiteturas, banco de dados e modelagem
 
Banco de dados geográficos - Aula de abertura
Banco de dados geográficos - Aula de aberturaBanco de dados geográficos - Aula de abertura
Banco de dados geográficos - Aula de abertura
 
Linguagem SQL e Extensões Espacias - Introdução
Linguagem SQL e Extensões Espacias - IntroduçãoLinguagem SQL e Extensões Espacias - Introdução
Linguagem SQL e Extensões Espacias - Introdução
 
Gödel’s incompleteness theorems
Gödel’s incompleteness theoremsGödel’s incompleteness theorems
Gödel’s incompleteness theorems
 
Turing e o problema da decisão
Turing e o problema da decisãoTuring e o problema da decisão
Turing e o problema da decisão
 
Introdução ao Prolog
Introdução ao PrologIntrodução ao Prolog
Introdução ao Prolog
 
Heap - Python
Heap - PythonHeap - Python
Heap - Python
 
Paradigma lógico
Paradigma lógicoParadigma lógico
Paradigma lógico
 
Aula 1 - introdução a fundamentos de computação
Aula 1 - introdução a fundamentos de computaçãoAula 1 - introdução a fundamentos de computação
Aula 1 - introdução a fundamentos de computação
 

Último

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 

Último (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

Relações (composição e agregação)

  • 1. Abstract classes and interfaces Sérgio Souza Costa Universidade Federaldo Maranhão 28 de junho de 2016 Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 1 / 17
  • 2. Based in Dan Pilone. “UML 2.0 in a Nutshell.” Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 2 / 17
  • 3. Summary Association Aggregation Composition Assignment Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 3 / 17
  • 4. Dependency The weakest relationship between classes, means that one class uses, or has knowledge of, another class. It is typically a transient relationship, meaning a dependent class briefly interacts with the target class but typically doesn’t retain a relationship with it for any real length of time. Are typically read as "...uses a...”.For example, if you have a class named Window that sends out a class named WindowClosingEvent when it is about to be closed, you would say "Window uses a WindowClosingEvent.” You show a dependency between classes using a dashed line with an arrow pointing from the dependent class to the class that is used. Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 4 / 17
  • 5. Association Associations are stronger than dependencies and typically indicate that one class retains a relationship to another class over an extended period of time. Are typically read as "...has a...". For example, if you have a class named Window that has a reference to the current mouse cursor, you would say "Window has a Cursor". . You show an association using a solid line between the classes participating in the relationship. Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 5 / 17
  • 6. Navigability “Associations have explicit notation to express navigability. If you can navigate from one class to another, you show an arrow in the direction of the class you can navigate to. ” “Because you can’t navigate from an instance of Cursor to an instance of Window, we explicitly show the navigability arrow and an X where appropriate.” Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 6 / 17
  • 7. Multiplicity You can express how many instances of a particular class are involved in a relationship. I You don’t specify a value, a multiplicity of 1 is assumed. To show a different value, simply place the multiplicity specification near the owned class. Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 7 / 17
  • 8. Example Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 8 / 17
  • 9. Example - Item public class Item { ... public Item(int c, int q, float v, Produto p){ codigo =c; qde = q; valor = v; prod = p; } public cal_valor(){ valor = qde * prog.get_preco(); } } Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 9 / 17
  • 10. Example - Produto public class Produto { private int codigo; private String nome; private float preco; public Produto(int c, String n, float p){ codigo=c; nome=n; preco=p; } public double get_preco(){ return preco; } } Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 10 / 17
  • 11. Example 2 Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 11 / 17
  • 12. Example 2 - Cliente import java.util.Vector; public class Cliente{ private String nome; private String endereco; private Vector ped; public Cliente(String n,String e){ nome=n; endereco=e; ped=newVector(); } public int get_size(){ return ped.size(); } Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 12 / 17
  • 13. Example 2 - Cliente public void add_pedido(Pedido p){ ped.addElement(p); } public Pedido get_pedido(int i){ return (Pedido)ped.elementAt(i); } public void exc_pedido(int id){ Pedido aux; int tam=ped.size(); for(inti=0;i<tam;i++){ aux=(Pedido)ped.elementAt(i); if(aux.get_id()==id){ ped.removeElementAt(i); } } }} Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 13 / 17
  • 14. Agregation Is a stronger version of association. Unlike association, aggregation typically implies ownership and may imply a relationship between lifelines. Aggregations are usually read as "...owns a...". For example, if you had a classed named Window that stored its position and size in a Rectangle class, you would say the "Window owns a Rectangle.” In the association example, Window doesn’t own the Cursor; Cursor was shared between all applications in the system.” Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 14 / 17
  • 15. Composition Composition represents a very strong relationship between classes, to the point of containment. Composition is used to capture a whole-part relationship. The lifetime of instances involved in composition relationships is almost always linked; if the larger, owning instance is destroyed, it almost always destroys the part piece. Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 15 / 17
  • 16. Composition and the design patterns The Gang of Four suggests a few strategies for creating good object- oriented designs. In particular, they suggest the following: Design to interfaces. Favor composition over inheritance Find what varies and encapsulate it. Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 16 / 17
  • 17. Assignment Implementem as classes e suas relações como no diagrama abaixo. Sérgio Souza Costa (Universidade Federaldo Maranhão) Paradigmas de Programação 28 de junho de 2016 17 / 17