God object

God object

Un God object ou objet omniscient est, dans le domaine de la programmation orientée objet, un objet qui reconnaît trop de choses ou fait trop de choses. Le god object est un exemple d'antipattern (ou anti-patron).

Sommaire

Description

Le principe général de la programmation structurée est de s'attaquer à un problème important en le divisant en plus petits problèmes à résoudre (stratégie de diviser pour régner). Une fois chacun des petits problèmes résolus, le problème général est automatiquement réglé. Ainsi, il n'y a qu'un objet auquel il doit être connu ou renseigné : lui-même. De la même façon, il n'y a qu'un seul ensemble de problèmes auquel un objet doit se confronter : l'ensemble des siens propres.

La programmation « god object » ne suit pas cette approche. Au lieu de cela, la plus grande partie du programme consiste en un seul bloc qui est renseigné sur tout et maintient constamment à jour données ou informations sur le programme, et fournit la plupart des fonctions et des algorithmes qui utilisent ces données. Du fait que cet objet supporte et organise tellement d'informations à lui seul, il joue un rôle identique à celui d'un dieu. Au lieu de blocs de programme communicant indépendamment entre eux et sans intermédiaire, les autres parties du programme sont dépendants de l'objet omniscient pour communiquer et prendre leurs informations. Comme l'objet omniscient est référencé par tout le reste de la programmation, la maintenance de celle-ci devient très difficile, y compris dans les plus ordonnés des programmes.

Un god object est la version « orientée-objet » de l'incapacité à concevoir correctement les sous-programmes dans un langage de programmation procédural, ou d'utiliser trop de variables globales pour y stocker des informations sur l'état du programme à un moment donné (comme les drapeaux).

Bien que créer un god object est considéré comme une mauvaise pratique de programmation, cette technique est à l'occasion utilisé dans les environnements critiques de programmation (comme les microcontrôleurs), où le gain dans la vitesse d'exécution et la centralisation du contrôle sont des facteurs plus importants que la facilité de maintenance et l'élégance de la programmation.

Notes et références

Voir aussi

Bibliographie

  • (en) Arthur J. Riel, Object-Oriented Design Heuristics, Boston, MA, Addison-Wesley, 1996, 8e éd., relié (ISBN 978-0-201-63385-6) (LCCN 95048396), « Chapter 3: Topologies of Action-Oriented Vs. Object-Oriented Applications » :

« 3.2: Do not create god classes/objects in your system. Be very suspicious of an abstraction whose name contains Driver, Manager, System, or Subsystem. »

 

Articles connexes

Liens externes


Wikimedia Foundation. 2010.

Contenu soumis à la licence CC-BY-SA. Source : Article God object de Wikipédia en français (auteurs)

Игры ⚽ Поможем написать реферат

Regardez d'autres dictionnaires:

  • God object — (deutsch: Gott Objekt ; auch: god class bzw. deutsch: Gottklasse) bezeichnet in der objektorientierten Programmierung ein Objekt, das zu viel weiß oder zu viel tut . Das God object ist ein Beispiel für ein Anti Pattern. Die grundlegende Idee der… …   Deutsch Wikipedia

  • God object — In object oriented programming, a God object is an object that knows too much or does too much. The God object is an example of an anti pattern. The basic idea behind structured programming is that a big problem is broken down into several… …   Wikipedia

  • Object (computer science) — In computer science, an object is any entity that can be manipulated by the commands of a programming language, such as a value, variable, function, or data structure. (With the later introduction of object oriented programming the same word,… …   Wikipedia

  • God — (g[o^]d), n. [AS. god; akin to OS. & D. god, OHG. got, G. gott, Icel. gu[eth], go[eth], Sw. & Dan. gud, Goth. gup, prob. orig. a p. p. from a root appearing in Skr. h[=u], p. p. h[=u]ta, to call upon, invoke, implore. [root]30. Cf. {Goodbye},… …   The Collaborative International Dictionary of English

  • God's acre — God God (g[o^]d), n. [AS. god; akin to OS. & D. god, OHG. got, G. gott, Icel. gu[eth], go[eth], Sw. & Dan. gud, Goth. gup, prob. orig. a p. p. from a root appearing in Skr. h[=u], p. p. h[=u]ta, to call upon, invoke, implore. [root]30. Cf.… …   The Collaborative International Dictionary of English

  • God's field — God God (g[o^]d), n. [AS. god; akin to OS. & D. god, OHG. got, G. gott, Icel. gu[eth], go[eth], Sw. & Dan. gud, Goth. gup, prob. orig. a p. p. from a root appearing in Skr. h[=u], p. p. h[=u]ta, to call upon, invoke, implore. [root]30. Cf.… …   The Collaborative International Dictionary of English

  • God's house — God God (g[o^]d), n. [AS. god; akin to OS. & D. god, OHG. got, G. gott, Icel. gu[eth], go[eth], Sw. & Dan. gud, Goth. gup, prob. orig. a p. p. from a root appearing in Skr. h[=u], p. p. h[=u]ta, to call upon, invoke, implore. [root]30. Cf.… …   The Collaborative International Dictionary of English

  • God's penny — God God (g[o^]d), n. [AS. god; akin to OS. & D. god, OHG. got, G. gott, Icel. gu[eth], go[eth], Sw. & Dan. gud, Goth. gup, prob. orig. a p. p. from a root appearing in Skr. h[=u], p. p. h[=u]ta, to call upon, invoke, implore. [root]30. Cf.… …   The Collaborative International Dictionary of English

  • God's Sunday — God God (g[o^]d), n. [AS. god; akin to OS. & D. god, OHG. got, G. gott, Icel. gu[eth], go[eth], Sw. & Dan. gud, Goth. gup, prob. orig. a p. p. from a root appearing in Skr. h[=u], p. p. h[=u]ta, to call upon, invoke, implore. [root]30. Cf.… …   The Collaborative International Dictionary of English

  • God — /god/, n., v., godded, godding, interj. n. 1. the one Supreme Being, the creator and ruler of the universe. 2. the Supreme Being considered with reference to a particular attribute: the God of Islam. 3. (l.c.) one of several deities, esp. a male… …   Universalium

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”