cours/principe de l'extension créative.md
Oscar Plaisant 2c61798962 update
2024-03-28 14:09:52 +01:00

4.0 KiB

up:: paradigme de programmation #informatique

[!definition] principe de l'extension créative Un paradigme de programmation est un ensemble de concept, mais tout ensemble de concepts ne forme pas un paradigme. Le principe de l'extension créative (creative extension principle) est une façon d'organiser des concepts pour gréer un véritable paradigme de programmation. ^definition

[!cite]- Programming Paradigms for Dummies: What Every Programmer Should Know - Page 16 Concepts are not combined arbitrarily to form paradigms. They can be organized according to the creative extension principle. This principle was first defined by Felleisen [18] and independently rediscovered in [50].

[!note] Notes Le principe de l'extension créative permet d'organiser les concepts pour former réellement un paradigme. ^SVNS3KNFaP4L4LCJZg5383243p8

Fonctionnement de l'extension créative

  1. Apparition d'une modification envahissante
    • résoudre un certain problème nécessite des modifications non-locales
  2. C'est le signe qu'un nouveau concept peut être découvert
  3. implémentation d'une solution dans le langage lui-même
  4. la simplicité est conservée / retrouvée (on évite les modifications envahissantes)

[!cite] Programming Paradigms for Dummies: What Every Programmer Should Know - Page 17 The common theme in these three scenarios (and many others!) is that we need to do pervasive (nonlocal) modifications of the program in order to handle a new concept. If the need for pervasive modifications manifests itself, we can take this as a sign that there is a new concept waiting to be discovered. By adding this concept to the language we no longer need these pervasive modifications and we recover the simplicity of the program.

[!note] Notes Modification envahissante = signe qu'un nouveau concept peut être découvert

ajouter ce concept au langage => éviter les modifications envahissantes => retrouver la simplicité ^6ZNVVQGIaP4L4LCJZg5383243p9

Exemples de modifications envahissantes et solutions

[!cite] Programming Paradigms for Dummies: What Every Programmer Should Know - Page 17 If we need to model updatable memory, that is, entities that remember and update their past, then we will have to add two arguments to all function calls relative to that entity. The arguments represent the input and output values of the memory. This is unwieldy and it is also not modular because the memory travels throughout the whole program. All this clumsiness is unnecessary if we add one concept to the language: named state.

[!note] Notes Les états nommés sont une solution efficace pour modéliser la mémoire que l'on peut mettre à jour.

Cela évite d'avoir à ajouter des arguments à toutes les fonctions qui utilisent cet état. ^VAZ8DBMAaP4L4LCJZg5383243p9

[!cite] Programming Paradigms for Dummies: What Every Programmer Should Know - Page 17 If we need to model error detection and correction, in which any function can detect an error at any time and transfer control to an error correction routine, then we need to add error codes to all function outputs and conditionals to test all function calls for returned error codes. All this complexity is unnecessary if we add one concept to the language: exceptions.

[!note] Notes les exceptions sont une solution efficace pour éviter d'avoir à gérer soi-même les codes d'erreurs, leur propagation etc. ^NKKRZRU4aP4L4LCJZg5383243p9