teaching:progappchim:ppoo

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
teaching:progappchim:ppoo [2016/06/20 17:15] – créée villersdteaching:progappchim:ppoo [2023/01/28 16:31] (Version actuelle) – [Références] villersd
Ligne 2: Ligne 2:
 FIXME : en construction FIXME : en construction
  
-  * Qu'est-ce qu'un objet ? +===== Concepts utilisés ===== 
-    C'est... n'importe quoi, qui peut être codé. En Python, tout est objet !+  Un objet : c'est... n'importe quoi, qui peut être codé. En Python, tout est objet ! 
 +  * Une classe est une description générique d'un type d'objet, incluant les données et les méthodes qui le caractérisent 
 +    * Convention : on écrit les noms de classe en "CamelCase" 
 +  * Une instance d'une classe, c'est un objet individuel bien précis, avec son identifiant, et toutes les propriétés liées à la classe à laquelle il appartient. 
 +    * Convention : les noms des instances commencent par une lettre en bas de casse (minuscule) 
 +  * Méthode : les objets peuvent évoluer par la réalisation de méthodes, qui sont des fonctions associées à des objets, pouvant accéder à leurs données. Comme toute fonction, les méthodes peuvent passer des arguments et renvoyer des valeurs 
 +  * Encapsulation : [[https://fr.wikipedia.org/wiki/Encapsulation_(programmation)]] 
 +  * Héritage : ... 
 +  * Abstraction 
 +  * Polymorphisme 
 + 
 + 
 +<code python intro-OO-01.py3> 
 +#!/usr/bin/env python3 
 +# -*- coding: utf-8 -*- 
 +"""  
 +Introduction to object-oriented programming in Python 
 + 
 +Led with number and status attributes 
 +""" 
 +class Led: 
 +    def __init__(self, number, status): 
 +        self.number = number 
 +        self.status = status 
 +    def on(self): 
 +        self.status = 'on' 
 +    def off(self): 
 +        self.status = 'off' 
 + 
 +led1 = Led(1, 'on'
 +print(led1) 
 +print(type(led1)) 
 +print(type(Led)) 
 +print(led1.number) 
 +print(led1.status) 
 +</code> 
 + 
 +===== Références ===== 
 +  * [[https://fr.wikipedia.org/wiki/Programmation_orient%C3%A9e_objet]] 
 +  * UML : 
 +    * [[https://fr.wikipedia.org/wiki/UML_(informatique)]] 
 +    * [[http://argouml.tigris.org/]] 
 +  * Vulgarisation 
 +    * [[https://towardsdatascience.com/how-i-explain-oop-to-a-data-scientist-in-5-minutes-44faf72ecca7|How I Explain OOP to a Data Scientist in 5 Minutes]] 
 +    * [[https://levelup.gitconnected.com/all-the-basics-of-python-classes-8b07046d2a52|All the basics of Python classes - Everything you need to know about Python classes!]] George Seif, Medium, 25/09/2019 
 +    * [[https://towardsdatascience.com/the-most-important-python-concept-that-you-need-to-understand-985b98bbb84|Python Objects and Classes: The Most Important Python Concepts That You Need to Understand]], Erik van Baaren, Medium, 13/07/2020 
 +    * [[https://towardsdatascience.com/object-oriented-programming-in-python-what-and-why-d966e9e0fd03|Object Oriented Programming in Python — What and Why? | by Arafath Hossain | Mar, 2022 | Towards Data Science]] 
 +    * [[https://towardsdatascience.com/oop-in-python-understanding-a-class-bcc088e595c6|OOP in Python - Understanding a Class | by Arafath Hossain | Mar, 2022 | Towards Data Science]] 
 +    * [[https://towardsdatascience.com/object-oriented-programming-in-python-understanding-variable-e451cf581368|Object Oriented Programming in Python — Understanding Variables | by Arafath Hossain | Mar, 2022 | Towards Data Science]] 
 +    * [[https://towardsdatascience.com/object-oriented-programming-in-python-inheritance-and-subclass-9c62ad027278|Object Oriented Programming in Python — Inheritance and Subclass | by Arafath Hossain | Mar, 2022 | Towards Data Science]] 
 +  * Alternatives 
 +    * [[https://betterprogramming.pub/6-alternatives-to-classes-in-python-6ecb7206377|6 Alternatives to Classes in Python]] Martin Thoma, Medium, Mars 2021 
 +  * Simplifications : 
 +    * [[https://docs.python.org/3/library/dataclasses.html|Dataclasses]] 
 +      * [[https://python.plainenglish.io/create-data-classes-in-python-64d6d84ebe7a|Create Data Classes in Python - This library will save you hours of coding]] Matteo, medium, 09/09/2021 
 +      * [[https://itnext.io/effortlessly-create-classes-in-python-with-dataclass-19412eada8be|Effortlessly Create Classes in Python with @dataclass]] Jacob Ferus, ITNEXT (Medium), 21/01/2023 
 + 
 + 
 + 
 + 
  
  • teaching/progappchim/ppoo.1466435727.txt.gz
  • Dernière modification : 2016/06/20 17:15
  • de villersd