Python - Orientação a Objetos com UML no Batismo Digital 3.0 da Faculdade JK de Santa Maria-DF

Embed Size (px)

Citation preview

1-0020 - Template - Clean Wavy (green)

Python

Orientao a Objetos com UML

Professor George Mendona

BATISMO DIGITALSemana AcadmicaAqui tem TI12 de novembro de 2016

Super Mini Tutorial Python

Linguagem de programao orientada a objetos

Funcional

Alto nvel

Interpretada

Semntica dinmica integrada

Visualmente atraente e de fcil interpretao e aprendizado

Reduzindo custo de desenvolvimento e manuteno

Para desenvolvimento de aplicativos, para web e mobile

Acessvel

Super Mini Tutorial Python

Simplista Mnimo esforo do programador sobre o esforo computacional

No utiliza begin/end, chaves ou qualquer outro delimitador

Identao obrigatria

Tipagem dinmida e forte

Criador: Guido van Rossum

Mantido pela Python Software Foundation

Super Mini Tutorial Python

# Comentriode 1 linha'''Comentrio de vrias linhas'''

# Variveissalario = 12000.0

# Funodef minhaFuncao(s): print('Meu salrio: %.2f')%(s)

minhaFuncao(salario) # Meu salrio: 12000.00

# Condicionalif salario > 5000.00: print('Snior')

# coding: utf-8

# coding: utf-8
# Comentriode 1 linha'''Comentrio de vriaslinhas'''# Variveissalario = 12000.0

# Funodef minhaFuncao(s): print('Meu salrio: %.2f')%(s)

# Chamando a funo e imprimindo salariominhaFuncao(salario)

if salario > 5000.00: print('Snior')

UML

Unified Modeling LanguageLinguagem de modelagem para o desenvolvimento de software

Que permite representar um sistema de forma padronizada

No uma metodologia, mas auxlilia na visualizao do modelo do projeto de software

Na construo de projetos orientado a objetos, facilita a comunicao entre os objetos

UML

Diagrama de classes

UML

Diagrama de classes

Classe minimalista em Python

Vamos comear com a classe mais simples em Python:

class Minima: pass

Herana em Python

Criando uma subclasse Herana

A herana tambm utilizada para a propagao de metaclasses (ver artigo Metaclasses em Python)

class Minima(object): pass

Object uma classe j existente do core do interpretador Python

Atributo em Python

Um atributo uma varivel da classe

class Empregado: salario = 8000.0

Instanciando um objeto em Python

Um atributo uma varivel da classe

class Empregado: salario = 8000.0 if __name__ == '__main__': obj = Empregado() print (obj.salario)

Console:8000.0

Atribuo privado e
Mtodo da classe em Python

O atributo uma varivel da classe

Console:8000.0

class Empregado: __salario = 8000.0 def getSal(self): return self.__salario if __name__ == '__main__': obj = Empregado() print (obj.getSal())

salario um atributo privado!S tem acesso na classe,no pode ser acessado fora da classe! Acesso via mtodo.

Salario Recuperadopelo mtodogetSal()

Transformando Funo em mtodo em Python - Classmethod

(funo) -> convertida em mtodo da classeUm mtodo de classe recebe a classe como primeiro argumento implcito,

Assim como um mtodo de instncia recebe a instncia

class ClasseMetodo: def f(self): print('Massa!')

if __name__ == '__main__': ClasseMetodo.f()

TypeError: unbound method f() must be called with MetodoClasse instance as first argument (got nothing instead)

f = classmethod(f)

Console:Massa!

Desafio em Python

Mo na massa!

Desafio em Python

Obrigado!

Click to edit the title text format

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline LevelNinth Outline LevelClick to edit Master subtitle style

Click to edit the title text format

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline LevelNinth Outline Level

20/11/2016

Your footer here

http://creativecommons.org/licenses/by-nd/3.0/

You can use this OpenOffice Impress template for your personal, educational and business presentations.

Conditions of use

The copyright statement we require you to include when you use our material is:
Copyright Showeet.com

http://www.showeet.com

Contact: [email protected] With the use of this free template you accept the following use and license conditions.

You are free:

To Share to copy, distribute and transmit the workUnder the following conditions:

Attribution You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).No Derivative Works You may not alter, transform, or build upon this work.

For any distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page: http://www.showeet.com/terms-of-use/

Any of the conditions can be waived if you get permission from showeet.comIn no event shall Showeet.com be liable for any indirect, special or consequential damages arising out of or in connection with the use of the template, diagram or map.