SlideShare a Scribd company logo
1 of 12
Download to read offline
UML + Python




                 Le minimum


                        Python

               UML


                              Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
CLASSE
UML + Python




                                                        Attribut:
                                                        chaque CompteCourant a le sien




                   Opération:
                   chaque CompteCourant sait le faire




                                                         Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
CLASSE
UML + Python




                    class CompteCourant(object):
                        def __init__(self):
                            # A la création, le solde est à zéro
                            self.solde = 0 # Solde en cents!

                        def crediter(self, montant):
                            self.solde += montant

                        def debiter(self, montant):
                            if self.solde < montant:
                                raise OperationRejetee();

                            self.solde -= montant


                                           Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
INTERFACE
UML + Python




                 Tous les Comptes possèdent les 
                       mêmes opérations
                                     Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
INTERFACE
UML + Python



                               Python est dynamique

                 Pas besoin de coder les interfaces

                        class CompteSurLivret(object):
                            def __init__(self, plafond):
                                # ...

                            # ...

                        class CompteCourant(object):
                            def __init__(self):
                                # ...

                            # ...

                                              Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
INTERFACE – option 1
UML + Python


                                  class Compte(object):

                Créer un stub         def crediter(self, montant):
                                          pass

               pour l'interface       def debiter(self, montant):
                                          pass


                                  class CompteSurLivret(Compte):
                                      def __init__(self, plafond):
                                          # ...


                 Faire hériter        # ...


                  les classes     class CompteCourant(Compte):
                                      def __init__(self):
                                          # ...

                                      # ...

                                              Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
INTERFACE – option 2
UML + Python


                                 class Compte(object):

                Variante avec        def crediter(self, montant):
                                         raise NonMisEnOeuvre()

                 exceptions          def debiter(self, montant):
                                         raise NonMisEnOeuvre()


                                 class CompteSurLivret(Compte):
                                     def __init__(self, plafond):
                                         # ...


                Faire hériter        # ...


                 les classes     class CompteCourant(Compte):
                                     def __init__(self):
                                         # ...

                                     # ...

                                             Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
HÉRITAGE
                     Quand la classe de base fait 
UML + Python




                   quelque­chose d'utile, on parle 
                                       d'héritage
                      class Compte(object):
                          def afficheSolde(self):
                              print "%+10.2f" % (self.solde / 100.0)

                          # ...

                      class CompteSurLivret(Compte):
                          # ...


                      if __name__ == '__main__':
                          compte = CompteSurLivret(10000)

                          compte.crediter(10000)
                          compte.afficheSolde()

                                           Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
AGRÉGATION
UML + Python




                     Chaque Client 
                possède un Compte

                class Client(object):
                    def __init__(self, compte):
                        self.compte = compte

                if __name__ == '__main__':
                    # John possède un compte courant
                    john = Client( CompteCourant() )
                    # Paul possède un compte sur livret
                    paul = Client( CompteSurLivret(5000000) )



                                                    Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
AGRÉGATION
UML + Python

                  class Client(object):
                      def __init__(self):
                          self.compte = []

                      def ajouteCompte(self, compte):
                          self.compte.append(compte)

                  if __name__ == '__main__':
                      ringo = Client()
                      ringo.ajouteCompte( CompteCourant() )
                      ringo.ajouteCompte( CompteCourant(5000000) )




                                  Chaque Client 
                                  possède des Comptes

                                              Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
DIAGRAMME
UML + Python



               DE SÉQUENCE

               if __name__ == '__main__':
                   unCompte = CompteCourant()
                   unCompte.crediter(10000)
                   unCompte.afficheSolde()




                                                Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
A VOUS DE JOUER!
UML + Python




                      Q&
                          R

                            Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0

More Related Content

What's hot

Formation python
Formation pythonFormation python
Formation pythonj_lipaz
 
Cours d'introduction aux HTML5 & CSS3
Cours d'introduction aux HTML5 & CSS3Cours d'introduction aux HTML5 & CSS3
Cours d'introduction aux HTML5 & CSS3Abel LIFAEFI MBULA
 
Rapport de stage développement informatique
Rapport de stage développement informatique Rapport de stage développement informatique
Rapport de stage développement informatique MehdiOuqas
 
BigData_TP5 : Neo4J
BigData_TP5 : Neo4JBigData_TP5 : Neo4J
BigData_TP5 : Neo4JLilia Sfaxi
 
Programmation orientée objet en PHP 5
Programmation orientée objet en PHP 5Programmation orientée objet en PHP 5
Programmation orientée objet en PHP 5Kristen Le Liboux
 
EXPOSE SUR L’ALGORITHME DU TRI À BULLES (BUBBLE SORT).
EXPOSE SUR L’ALGORITHME DU TRI À BULLES (BUBBLE SORT).EXPOSE SUR L’ALGORITHME DU TRI À BULLES (BUBBLE SORT).
EXPOSE SUR L’ALGORITHME DU TRI À BULLES (BUBBLE SORT).vangogue
 
Introduction à React JS
Introduction à React JSIntroduction à React JS
Introduction à React JSAbdoulaye Dieng
 
Cours java avance débutant facile l'essentiel swing ,events
Cours java avance débutant facile l'essentiel swing ,events Cours java avance débutant facile l'essentiel swing ,events
Cours java avance débutant facile l'essentiel swing ,events Houssem Hamrouni
 
Paramétrage et développement spécifique des modules odoo(OpenERP) Partie 1
Paramétrage et développement spécifique des modules odoo(OpenERP) Partie 1Paramétrage et développement spécifique des modules odoo(OpenERP) Partie 1
Paramétrage et développement spécifique des modules odoo(OpenERP) Partie 1Addi Ait-Mlouk
 
Formation JAVA/J2EE
Formation JAVA/J2EEFormation JAVA/J2EE
Formation JAVA/J2EEInes Ouaz
 
Correction Examen 2016-2017 POO .pdf
Correction Examen 2016-2017 POO .pdfCorrection Examen 2016-2017 POO .pdf
Correction Examen 2016-2017 POO .pdfslimyaich3
 
Ecole ESMA : Projet Fin de semestre - Application de gestion d'une école - Di...
Ecole ESMA : Projet Fin de semestre - Application de gestion d'une école - Di...Ecole ESMA : Projet Fin de semestre - Application de gestion d'une école - Di...
Ecole ESMA : Projet Fin de semestre - Application de gestion d'une école - Di...Mehdi Hamime
 
Examen principal - PHP
Examen principal - PHPExamen principal - PHP
Examen principal - PHPInes Ouaz
 
Exercices sur-python-turtle-corrige
Exercices sur-python-turtle-corrigeExercices sur-python-turtle-corrige
Exercices sur-python-turtle-corrigeWajihBaghdadi1
 
Tp1 - WS avec JAXWS
Tp1 - WS avec JAXWSTp1 - WS avec JAXWS
Tp1 - WS avec JAXWSLilia Sfaxi
 
JDBC: Gestion des bases de données en Java
JDBC: Gestion des bases de données en Java JDBC: Gestion des bases de données en Java
JDBC: Gestion des bases de données en Java Youness Boukouchi
 
Gestion d’une agence de voyage routière (Blondel Seumo)
Gestion d’une  agence  de  voyage  routière (Blondel Seumo)Gestion d’une  agence  de  voyage  routière (Blondel Seumo)
Gestion d’une agence de voyage routière (Blondel Seumo)Gantner Technologies
 

What's hot (20)

Corrige tp java
Corrige tp javaCorrige tp java
Corrige tp java
 
Formation python
Formation pythonFormation python
Formation python
 
Cours d'introduction aux HTML5 & CSS3
Cours d'introduction aux HTML5 & CSS3Cours d'introduction aux HTML5 & CSS3
Cours d'introduction aux HTML5 & CSS3
 
Rapport de stage développement informatique
Rapport de stage développement informatique Rapport de stage développement informatique
Rapport de stage développement informatique
 
BigData_TP5 : Neo4J
BigData_TP5 : Neo4JBigData_TP5 : Neo4J
BigData_TP5 : Neo4J
 
Programmation orientée objet en PHP 5
Programmation orientée objet en PHP 5Programmation orientée objet en PHP 5
Programmation orientée objet en PHP 5
 
EXPOSE SUR L’ALGORITHME DU TRI À BULLES (BUBBLE SORT).
EXPOSE SUR L’ALGORITHME DU TRI À BULLES (BUBBLE SORT).EXPOSE SUR L’ALGORITHME DU TRI À BULLES (BUBBLE SORT).
EXPOSE SUR L’ALGORITHME DU TRI À BULLES (BUBBLE SORT).
 
Introduction à React JS
Introduction à React JSIntroduction à React JS
Introduction à React JS
 
Cours java avance débutant facile l'essentiel swing ,events
Cours java avance débutant facile l'essentiel swing ,events Cours java avance débutant facile l'essentiel swing ,events
Cours java avance débutant facile l'essentiel swing ,events
 
Introduction au langage SQL
Introduction au langage SQLIntroduction au langage SQL
Introduction au langage SQL
 
Paramétrage et développement spécifique des modules odoo(OpenERP) Partie 1
Paramétrage et développement spécifique des modules odoo(OpenERP) Partie 1Paramétrage et développement spécifique des modules odoo(OpenERP) Partie 1
Paramétrage et développement spécifique des modules odoo(OpenERP) Partie 1
 
Formation JAVA/J2EE
Formation JAVA/J2EEFormation JAVA/J2EE
Formation JAVA/J2EE
 
Support Web Services SOAP et RESTful Mr YOUSSFI
Support Web Services SOAP et RESTful Mr YOUSSFISupport Web Services SOAP et RESTful Mr YOUSSFI
Support Web Services SOAP et RESTful Mr YOUSSFI
 
Correction Examen 2016-2017 POO .pdf
Correction Examen 2016-2017 POO .pdfCorrection Examen 2016-2017 POO .pdf
Correction Examen 2016-2017 POO .pdf
 
Ecole ESMA : Projet Fin de semestre - Application de gestion d'une école - Di...
Ecole ESMA : Projet Fin de semestre - Application de gestion d'une école - Di...Ecole ESMA : Projet Fin de semestre - Application de gestion d'une école - Di...
Ecole ESMA : Projet Fin de semestre - Application de gestion d'une école - Di...
 
Examen principal - PHP
Examen principal - PHPExamen principal - PHP
Examen principal - PHP
 
Exercices sur-python-turtle-corrige
Exercices sur-python-turtle-corrigeExercices sur-python-turtle-corrige
Exercices sur-python-turtle-corrige
 
Tp1 - WS avec JAXWS
Tp1 - WS avec JAXWSTp1 - WS avec JAXWS
Tp1 - WS avec JAXWS
 
JDBC: Gestion des bases de données en Java
JDBC: Gestion des bases de données en Java JDBC: Gestion des bases de données en Java
JDBC: Gestion des bases de données en Java
 
Gestion d’une agence de voyage routière (Blondel Seumo)
Gestion d’une  agence  de  voyage  routière (Blondel Seumo)Gestion d’une  agence  de  voyage  routière (Blondel Seumo)
Gestion d’une agence de voyage routière (Blondel Seumo)
 

Viewers also liked

All about you knee
All about you kneeAll about you knee
All about you kneeConsultonmic
 
Cypyth formation-programmation-objet-en-langage-python
Cypyth formation-programmation-objet-en-langage-pythonCypyth formation-programmation-objet-en-langage-python
Cypyth formation-programmation-objet-en-langage-pythonCERTyou Formation
 
OpenStack Havana, tour d'horizon
OpenStack Havana, tour d'horizonOpenStack Havana, tour d'horizon
OpenStack Havana, tour d'horizonYannick Foeillet
 
SeSQL : un moteur de recherche en Python et PostgreSQL
SeSQL : un moteur de recherche en Python et PostgreSQLSeSQL : un moteur de recherche en Python et PostgreSQL
SeSQL : un moteur de recherche en Python et PostgreSQLParis, France
 
Les langages de programmation sont trop compliqués
Les langages de programmation sont trop compliquésLes langages de programmation sont trop compliqués
Les langages de programmation sont trop compliquésmercury_wood
 
Base NoSql et Python
Base NoSql et PythonBase NoSql et Python
Base NoSql et Pythonyboussard
 
Modelisation agile 03122011
Modelisation agile  03122011Modelisation agile  03122011
Modelisation agile 03122011agnes_crepet
 
Chp3 - Diagramme de Classes
Chp3 - Diagramme de ClassesChp3 - Diagramme de Classes
Chp3 - Diagramme de ClassesLilia Sfaxi
 
Python et son intégration avec Odoo
Python et son intégration avec OdooPython et son intégration avec Odoo
Python et son intégration avec OdooHassan WAHSISS
 
Vijay Mewada June 11
Vijay Mewada June 11Vijay Mewada June 11
Vijay Mewada June 11vsa177
 
20101109 college univ-leiden_oj
20101109 college univ-leiden_oj20101109 college univ-leiden_oj
20101109 college univ-leiden_ojOlaf Janssen
 
Gripex Kichajacy Portal 2006
Gripex Kichajacy Portal 2006Gripex Kichajacy Portal 2006
Gripex Kichajacy Portal 2006Next
 
Going mobile in accounting education upload
Going mobile in accounting education uploadGoing mobile in accounting education upload
Going mobile in accounting education uploadYaneli Cruz
 

Viewers also liked (20)

All about you knee
All about you kneeAll about you knee
All about you knee
 
Cypyth formation-programmation-objet-en-langage-python
Cypyth formation-programmation-objet-en-langage-pythonCypyth formation-programmation-objet-en-langage-python
Cypyth formation-programmation-objet-en-langage-python
 
OpenStack Havana, tour d'horizon
OpenStack Havana, tour d'horizonOpenStack Havana, tour d'horizon
OpenStack Havana, tour d'horizon
 
La sabiduría
La sabiduríaLa sabiduría
La sabiduría
 
Solucion y Psicologia del Bienestar
Solucion y Psicologia del BienestarSolucion y Psicologia del Bienestar
Solucion y Psicologia del Bienestar
 
Python debugger
Python debuggerPython debugger
Python debugger
 
SeSQL : un moteur de recherche en Python et PostgreSQL
SeSQL : un moteur de recherche en Python et PostgreSQLSeSQL : un moteur de recherche en Python et PostgreSQL
SeSQL : un moteur de recherche en Python et PostgreSQL
 
Les langages de programmation sont trop compliqués
Les langages de programmation sont trop compliquésLes langages de programmation sont trop compliqués
Les langages de programmation sont trop compliqués
 
Base NoSql et Python
Base NoSql et PythonBase NoSql et Python
Base NoSql et Python
 
Modelisation agile 03122011
Modelisation agile  03122011Modelisation agile  03122011
Modelisation agile 03122011
 
Chp3 - Diagramme de Classes
Chp3 - Diagramme de ClassesChp3 - Diagramme de Classes
Chp3 - Diagramme de Classes
 
Python et son intégration avec Odoo
Python et son intégration avec OdooPython et son intégration avec Odoo
Python et son intégration avec Odoo
 
Widgets
WidgetsWidgets
Widgets
 
malik banner
malik bannermalik banner
malik banner
 
Vijay Mewada June 11
Vijay Mewada June 11Vijay Mewada June 11
Vijay Mewada June 11
 
20101109 college univ-leiden_oj
20101109 college univ-leiden_oj20101109 college univ-leiden_oj
20101109 college univ-leiden_oj
 
Gripex Kichajacy Portal 2006
Gripex Kichajacy Portal 2006Gripex Kichajacy Portal 2006
Gripex Kichajacy Portal 2006
 
Facebook2E-mail
Facebook2E-mailFacebook2E-mail
Facebook2E-mail
 
Going mobile in accounting education upload
Going mobile in accounting education uploadGoing mobile in accounting education upload
Going mobile in accounting education upload
 
My Future
My FutureMy Future
My Future
 

More from Sylvain Leroux

More from Sylvain Leroux (8)

ModèLes DexéCution
ModèLes DexéCutionModèLes DexéCution
ModèLes DexéCution
 
Le Jdk En 5 Minutes
Le Jdk En 5 MinutesLe Jdk En 5 Minutes
Le Jdk En 5 Minutes
 
Java Platform
Java PlatformJava Platform
Java Platform
 
Premier contact avec Subversion
Premier contact avec SubversionPremier contact avec Subversion
Premier contact avec Subversion
 
Notion de fonction en Python
Notion de fonction en PythonNotion de fonction en Python
Notion de fonction en Python
 
Poo
PooPoo
Poo
 
Variables variables
Variables variablesVariables variables
Variables variables
 
Merise vs UML
Merise vs UMLMerise vs UML
Merise vs UML
 

Recently uploaded

le present des verbes reguliers -er.pptx
le present des verbes reguliers -er.pptxle present des verbes reguliers -er.pptx
le present des verbes reguliers -er.pptxmmatar2
 
Presentation de la plateforme Moodle - avril 2024
Presentation de la plateforme Moodle - avril 2024Presentation de la plateforme Moodle - avril 2024
Presentation de la plateforme Moodle - avril 2024Gilles Le Page
 
SciencesPo_Aix_InnovationPédagogique_Atelier_IA.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_IA.pdfSciencesPo_Aix_InnovationPédagogique_Atelier_IA.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_IA.pdfSKennel
 
Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .
Annie   Ernaux  Extérieurs. pptx. Exposition basée sur un livre .Annie   Ernaux  Extérieurs. pptx. Exposition basée sur un livre .
Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .Txaruka
 
SciencesPo_Aix_InnovationPédagogique_Conférence_SK.pdf
SciencesPo_Aix_InnovationPédagogique_Conférence_SK.pdfSciencesPo_Aix_InnovationPédagogique_Conférence_SK.pdf
SciencesPo_Aix_InnovationPédagogique_Conférence_SK.pdfSKennel
 
Bernard Réquichot.pptx Peintre français
Bernard Réquichot.pptx   Peintre françaisBernard Réquichot.pptx   Peintre français
Bernard Réquichot.pptx Peintre françaisTxaruka
 
Zotero avancé - support de formation doctorants SHS 2024
Zotero avancé - support de formation doctorants SHS 2024Zotero avancé - support de formation doctorants SHS 2024
Zotero avancé - support de formation doctorants SHS 2024Alain Marois
 
Principe de fonctionnement d'un moteur 4 temps
Principe de fonctionnement d'un moteur 4 tempsPrincipe de fonctionnement d'un moteur 4 temps
Principe de fonctionnement d'un moteur 4 tempsRajiAbdelghani
 
SciencesPo_Aix_InnovationPédagogique_Atelier_FormationRecherche.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_FormationRecherche.pdfSciencesPo_Aix_InnovationPédagogique_Atelier_FormationRecherche.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_FormationRecherche.pdfSKennel
 
Présentation_ Didactique 1_SVT (S4) complet.pptx
Présentation_ Didactique 1_SVT (S4) complet.pptxPrésentation_ Didactique 1_SVT (S4) complet.pptx
Présentation_ Didactique 1_SVT (S4) complet.pptxrababouerdighi
 
Bibdoc 2024 - Ecologie du livre et creation de badge.pdf
Bibdoc 2024 - Ecologie du livre et creation de badge.pdfBibdoc 2024 - Ecologie du livre et creation de badge.pdf
Bibdoc 2024 - Ecologie du livre et creation de badge.pdfBibdoc 37
 
Cours SE Gestion des périphériques - IG IPSET
Cours SE Gestion des périphériques - IG IPSETCours SE Gestion des périphériques - IG IPSET
Cours SE Gestion des périphériques - IG IPSETMedBechir
 
Cours SE Le système Linux : La ligne de commande bash - IG IPSET
Cours SE Le système Linux : La ligne de commande bash - IG IPSETCours SE Le système Linux : La ligne de commande bash - IG IPSET
Cours SE Le système Linux : La ligne de commande bash - IG IPSETMedBechir
 
Saint Georges, martyr, et la lègend du dragon.pptx
Saint Georges, martyr, et la lègend du dragon.pptxSaint Georges, martyr, et la lègend du dragon.pptx
Saint Georges, martyr, et la lègend du dragon.pptxMartin M Flynn
 
LA MONTÉE DE L'ÉDUCATION DANS LE MONDE DE LA PRÉHISTOIRE À L'ÈRE CONTEMPORAIN...
LA MONTÉE DE L'ÉDUCATION DANS LE MONDE DE LA PRÉHISTOIRE À L'ÈRE CONTEMPORAIN...LA MONTÉE DE L'ÉDUCATION DANS LE MONDE DE LA PRÉHISTOIRE À L'ÈRE CONTEMPORAIN...
LA MONTÉE DE L'ÉDUCATION DANS LE MONDE DE LA PRÉHISTOIRE À L'ÈRE CONTEMPORAIN...Faga1939
 
Le Lean sur une ligne de production : Formation et mise en application directe
Le Lean sur une ligne de production : Formation et mise en application directeLe Lean sur une ligne de production : Formation et mise en application directe
Le Lean sur une ligne de production : Formation et mise en application directeXL Groupe
 
SciencesPo_Aix_InnovationPédagogique_Atelier_EtudiantActeur.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_EtudiantActeur.pdfSciencesPo_Aix_InnovationPédagogique_Atelier_EtudiantActeur.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_EtudiantActeur.pdfSKennel
 
SciencesPo_Aix_InnovationPédagogique_Bilan.pdf
SciencesPo_Aix_InnovationPédagogique_Bilan.pdfSciencesPo_Aix_InnovationPédagogique_Bilan.pdf
SciencesPo_Aix_InnovationPédagogique_Bilan.pdfSKennel
 
Evaluation du systeme d'Education. Marocpptx
Evaluation du systeme d'Education. MarocpptxEvaluation du systeme d'Education. Marocpptx
Evaluation du systeme d'Education. MarocpptxAsmaa105193
 

Recently uploaded (20)

le present des verbes reguliers -er.pptx
le present des verbes reguliers -er.pptxle present des verbes reguliers -er.pptx
le present des verbes reguliers -er.pptx
 
Presentation de la plateforme Moodle - avril 2024
Presentation de la plateforme Moodle - avril 2024Presentation de la plateforme Moodle - avril 2024
Presentation de la plateforme Moodle - avril 2024
 
SciencesPo_Aix_InnovationPédagogique_Atelier_IA.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_IA.pdfSciencesPo_Aix_InnovationPédagogique_Atelier_IA.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_IA.pdf
 
Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .
Annie   Ernaux  Extérieurs. pptx. Exposition basée sur un livre .Annie   Ernaux  Extérieurs. pptx. Exposition basée sur un livre .
Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .
 
SciencesPo_Aix_InnovationPédagogique_Conférence_SK.pdf
SciencesPo_Aix_InnovationPédagogique_Conférence_SK.pdfSciencesPo_Aix_InnovationPédagogique_Conférence_SK.pdf
SciencesPo_Aix_InnovationPédagogique_Conférence_SK.pdf
 
Bernard Réquichot.pptx Peintre français
Bernard Réquichot.pptx   Peintre françaisBernard Réquichot.pptx   Peintre français
Bernard Réquichot.pptx Peintre français
 
Zotero avancé - support de formation doctorants SHS 2024
Zotero avancé - support de formation doctorants SHS 2024Zotero avancé - support de formation doctorants SHS 2024
Zotero avancé - support de formation doctorants SHS 2024
 
Principe de fonctionnement d'un moteur 4 temps
Principe de fonctionnement d'un moteur 4 tempsPrincipe de fonctionnement d'un moteur 4 temps
Principe de fonctionnement d'un moteur 4 temps
 
SciencesPo_Aix_InnovationPédagogique_Atelier_FormationRecherche.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_FormationRecherche.pdfSciencesPo_Aix_InnovationPédagogique_Atelier_FormationRecherche.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_FormationRecherche.pdf
 
DO PALÁCIO À ASSEMBLEIA .
DO PALÁCIO À ASSEMBLEIA                 .DO PALÁCIO À ASSEMBLEIA                 .
DO PALÁCIO À ASSEMBLEIA .
 
Présentation_ Didactique 1_SVT (S4) complet.pptx
Présentation_ Didactique 1_SVT (S4) complet.pptxPrésentation_ Didactique 1_SVT (S4) complet.pptx
Présentation_ Didactique 1_SVT (S4) complet.pptx
 
Bibdoc 2024 - Ecologie du livre et creation de badge.pdf
Bibdoc 2024 - Ecologie du livre et creation de badge.pdfBibdoc 2024 - Ecologie du livre et creation de badge.pdf
Bibdoc 2024 - Ecologie du livre et creation de badge.pdf
 
Cours SE Gestion des périphériques - IG IPSET
Cours SE Gestion des périphériques - IG IPSETCours SE Gestion des périphériques - IG IPSET
Cours SE Gestion des périphériques - IG IPSET
 
Cours SE Le système Linux : La ligne de commande bash - IG IPSET
Cours SE Le système Linux : La ligne de commande bash - IG IPSETCours SE Le système Linux : La ligne de commande bash - IG IPSET
Cours SE Le système Linux : La ligne de commande bash - IG IPSET
 
Saint Georges, martyr, et la lègend du dragon.pptx
Saint Georges, martyr, et la lègend du dragon.pptxSaint Georges, martyr, et la lègend du dragon.pptx
Saint Georges, martyr, et la lègend du dragon.pptx
 
LA MONTÉE DE L'ÉDUCATION DANS LE MONDE DE LA PRÉHISTOIRE À L'ÈRE CONTEMPORAIN...
LA MONTÉE DE L'ÉDUCATION DANS LE MONDE DE LA PRÉHISTOIRE À L'ÈRE CONTEMPORAIN...LA MONTÉE DE L'ÉDUCATION DANS LE MONDE DE LA PRÉHISTOIRE À L'ÈRE CONTEMPORAIN...
LA MONTÉE DE L'ÉDUCATION DANS LE MONDE DE LA PRÉHISTOIRE À L'ÈRE CONTEMPORAIN...
 
Le Lean sur une ligne de production : Formation et mise en application directe
Le Lean sur une ligne de production : Formation et mise en application directeLe Lean sur une ligne de production : Formation et mise en application directe
Le Lean sur une ligne de production : Formation et mise en application directe
 
SciencesPo_Aix_InnovationPédagogique_Atelier_EtudiantActeur.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_EtudiantActeur.pdfSciencesPo_Aix_InnovationPédagogique_Atelier_EtudiantActeur.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_EtudiantActeur.pdf
 
SciencesPo_Aix_InnovationPédagogique_Bilan.pdf
SciencesPo_Aix_InnovationPédagogique_Bilan.pdfSciencesPo_Aix_InnovationPédagogique_Bilan.pdf
SciencesPo_Aix_InnovationPédagogique_Bilan.pdf
 
Evaluation du systeme d'Education. Marocpptx
Evaluation du systeme d'Education. MarocpptxEvaluation du systeme d'Education. Marocpptx
Evaluation du systeme d'Education. Marocpptx
 

UML+Python

  • 1. UML + Python Le minimum Python UML Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
  • 2. CLASSE UML + Python Attribut: chaque CompteCourant a le sien Opération: chaque CompteCourant sait le faire Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
  • 3. CLASSE UML + Python class CompteCourant(object): def __init__(self): # A la création, le solde est à zéro self.solde = 0 # Solde en cents! def crediter(self, montant): self.solde += montant def debiter(self, montant): if self.solde < montant: raise OperationRejetee(); self.solde -= montant Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
  • 4. INTERFACE UML + Python Tous les Comptes possèdent les  mêmes opérations Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
  • 5. INTERFACE UML + Python Python est dynamique Pas besoin de coder les interfaces class CompteSurLivret(object): def __init__(self, plafond): # ... # ... class CompteCourant(object): def __init__(self): # ... # ... Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
  • 6. INTERFACE – option 1 UML + Python class Compte(object): Créer un stub  def crediter(self, montant): pass pour l'interface def debiter(self, montant): pass class CompteSurLivret(Compte): def __init__(self, plafond): # ... Faire hériter # ... les classes class CompteCourant(Compte): def __init__(self): # ... # ... Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
  • 7. INTERFACE – option 2 UML + Python class Compte(object): Variante avec  def crediter(self, montant): raise NonMisEnOeuvre() exceptions def debiter(self, montant): raise NonMisEnOeuvre() class CompteSurLivret(Compte): def __init__(self, plafond): # ... Faire hériter # ... les classes class CompteCourant(Compte): def __init__(self): # ... # ... Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
  • 8. HÉRITAGE Quand la classe de base fait  UML + Python quelque­chose d'utile, on parle  d'héritage class Compte(object): def afficheSolde(self): print "%+10.2f" % (self.solde / 100.0) # ... class CompteSurLivret(Compte): # ... if __name__ == '__main__': compte = CompteSurLivret(10000) compte.crediter(10000) compte.afficheSolde() Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
  • 9. AGRÉGATION UML + Python Chaque Client  possède un Compte class Client(object): def __init__(self, compte): self.compte = compte if __name__ == '__main__': # John possède un compte courant john = Client( CompteCourant() ) # Paul possède un compte sur livret paul = Client( CompteSurLivret(5000000) ) Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
  • 10. AGRÉGATION UML + Python class Client(object): def __init__(self): self.compte = [] def ajouteCompte(self, compte): self.compte.append(compte) if __name__ == '__main__': ringo = Client() ringo.ajouteCompte( CompteCourant() ) ringo.ajouteCompte( CompteCourant(5000000) ) Chaque Client  possède des Comptes Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
  • 11. DIAGRAMME UML + Python DE SÉQUENCE if __name__ == '__main__': unCompte = CompteCourant() unCompte.crediter(10000) unCompte.afficheSolde() Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0
  • 12. A VOUS DE JOUER! UML + Python Q& R Sylvain Leroux – www.chicoree.fr – 2009 – Licence CC-BY3.0